Location: PHPKode > projects > Grocery List > GL_matchItem_Form.php
<?php
########################################################################
#
# Project: Grocery List
# URL: http://sourceforge.net/projects/grocery-list/
#
# Copyright: (C) 2007, James Campbell
# License: GNU General Public License Version 3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Filename: $URL: https://grocery-list.svn.sourceforge.net/svnroot/grocery-list/releases/1.0/GL_matchItem_Form.php $
# Last Updated: $Date: 2010-03-06 00:03:07 -0800 (Sat, 06 Mar 2010) $
# Author(s): James Campbell
#
########################################################################

$title = 'Matching Item';
include_once("include/header.php");
?>


<p>There is a similar item already in the list</p>


<form name="list" action="matchresultGLitem.php">

<?php


$matchnum = isset($_GET["matchnum"]) ? $_GET["matchnum"] : "";
$Quantity = isset($_GET["Quantity"]) ? $_GET["Quantity"] : "";
$Name = isset($_GET["Name"]) ? $_GET["Name"] : "";
$mfctr = isset($_GET["mfctr"]) ? $_GET["mfctr"] : "";
$Notes = isset($_GET["Notes"]) ? $_GET["Notes"] : "";
$Size = isset($_GET["Size"]) ? $_GET["Size"] : "";
$units = isset($_GET["units"]) ? $_GET["units"] : "";
$matchstring = isset($_GET["matchstring"]) ? $_GET["matchstring"] : "";

if($matchnum>1)
{
	echo "Existing Items";
	echo "<TABLE BORDER=1 align=\"center\">";
	echo "<TR><TH></TH><TH>Item ID</TH><TH>Quantity</TH><TH>Name</TH><TH>Size</TH><TH>Units</TH><TH>MFCTR</TH><TH>Notes</TH><TH>Time Added</TH></TR>";
}
else
{
	echo "Existing Item";
	echo "<TABLE BORDER=1 align=\"center\">";
	echo "<TR><TH>Item ID</TH><TH>Quantity</TH><TH>Name</TH><TH>Size</TH><TH>Units</TH><TH>MFCTR</TH><TH>Notes</TH><TH>Time Added</TH></TR>";
}

$connection = dbconnect();

$matchID = 0;
$start = 0;
$end = 0;

for($i=0;$i<$matchnum;$i++)
{
	$end = strpos($matchstring, ",", $start);

	$matchID = substr($matchstring, $start, $end-$start);

	$start = $end+1;	

	$sql = "select * from groceries where itemid = $matchID";

	$sql_result = $connection->query($sql);

	$row = $sql_result->fetch();
	$extitemid = $row["itemid"];
	$extquan = $row["quantity"];
	$extname = $row["itemname"];
	$extsize = $row["size"];
	$extunits = $row["units"];
	$extmfctr = $row["manufacturer"];
	$extnotes = $row["notes"];
	$exttime = $row["time"];

	if($matchnum>1)
	{
		if($i==0)
		{
			echo "<TR><TH><input type=\"radio\" name=\"matchID\" value=\"$extitemid\" checked></TH><TH>$extitemid</TH><TH>$extquan</TH><TH>$extname</TH><TH>$extsize</TH><TH>$extunits</TH><TH>$extmfctr</TH><TH>$extnotes</TH><TH>$exttime</TH></TR>";
		}		
		else
		{
			echo "<TR><TH><input type=\"radio\" name=\"matchID\" value=\"$extitemid\"></TH><TH>$extitemid</TH><TH>$extquan</TH><TH>$extname</TH><TH>$extsize</TH><TH>$extunits</TH><TH>$extmfctr</TH><TH>$extnotes</TH><TH>$exttime</TH></TR>";
		}
	}
	else
	{
		echo "<TR><TH>$extitemid</TH><TH>$extquan</TH><TH>$extname</TH><TH>$extsize</TH><TH>$extunits</TH><TH>$extmfctr</TH><TH>$extnotes</TH><TH>$exttime</TH></TR>";
		echo "<input  type=\"hidden\" name=\"matchID\" value=\"$extitemid\">";
	}

}
//mysql_free_result($sql_result);
//mysql_close($connection);
$connection = NULL;

$decname = urldecode($Name);
$decmfctr = urldecode($mfctr);
$decnotes = urldecode($Notes);

echo "</TABLE>";

echo "<br><br>Item you just entered";
echo "<TABLE BORDER=1 align=\"center\">";
echo "<TR><TH>Quantity</TH><TH>Name</TH><TH>Size</TH><TH>Units</TH><TH>MFCTR</TH><TH>Notes</TH></TR>";
echo "<TR><TH>$Quantity</TH><TH>$decname</TH><TH>$Size</TH><TH>$units</TH><TH>$decmfctr</TH><TH>$decnotes</TH></TR>";
echo "</TABLE>";

$encname = urlencode($decname);
$encmfctr = urlencode($decmfctr);
$encnotes = urlencode($decnotes);


echo "<input name=\"Quantity\" value=\"$Quantity\" type=\"hidden\">";
echo "<input name=\"Name\" value=\"$encname\" type=\"hidden\">";
echo "<input name=\"Size\" value=\"$Size\" type=\"hidden\">";
echo "<input name=\"units\" value=\"$units\" type=\"hidden\">";
echo "<input name=\"mfctr\" value=\"$encmfctr\" type=\"hidden\">";
echo "<input name=\"Notes\" value=\"$encnotes\" type=\"hidden\">";

?>





<input name="Complete" value="Edit Existing Item" type="Submit">
<input name="Complete" value="Add As A New Item" type="Submit">
<input name="Complete" value="Cancel" type="Submit">

</form>

<?php

include_once($WEBROOT . "/include/footer.php");

?>

Return current item: Grocery List