Location: PHPKode > projects > Grocery List > checkformatchingGLitem.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/checkformatchingGLitem.php $
# Last Updated: $Date: 2010-03-06 00:03:07 -0800 (Sat, 06 Mar 2010) $
# Author(s): James Campbell
#
########################################################################

include_once("include/site.php");

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

$Complete = isset($_GET["Complete"]) ? $_GET["Complete"] : "";

if($Complete == "Cancel")

{
	
	$loc = "GroceryList.php";
	
	header("Location: $loc");

	exit;


}



$connection = dbconnect();
$sql = "select * from groceries";
//$sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");
$sql_result = $connection->query($sql);

$matchnum = 0;

foreach ($sql_result as $row)
{
	$itemid = $row["itemid"];
	$extname = $row["itemname"];


	
	if($Name==$extname)
	{
		$match = $match . "$itemid,";	
		$matchnum = $matchnum + 1;
	}
	
}

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

$encname = urlencode($Name);
$encmfctr = urlencode($mfctr);
$encnotes = urlencode($Notes);


if($match==0)
{
	$loc = 	"addGLItem.php?Quantity=$Quantity&Name=$encname&Size=$Size&units=$units&mfctr=$encmfctr&Notes=$encnotes";

	header("Location: $loc");
	exit;
}
else
{
	$loc = 	"GL_matchItem_Form.php?matchnum=$matchnum&matchstring=$match&Quantity=$Quantity&Name=$encname&Size=$Size&units=$units&mfctr=$encmfctr&Notes=$encnotes";

	header("Location: $loc");
	exit;
}




?>

Return current item: Grocery List