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

$title = 'Edit Item';
$onload = 'list.Complete.focus();';
include_once("include/header.php");
?>

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

<?php

$val = isset($_POST['ItemFunc']) ? $_POST['ItemFunc'] : ""; 
$cba = isset($_POST['cb']) ? $_POST['cb'] : "";
$matchID = isset($_GET['matchID']) ? $_GET['matchID'] : "";


if($val)
{

	switch ($val)
	{
		case "Delete":
			$dest = "confirmdelGLitem.php";
			break;
		case "Print":
			$dest = "GL_printitem_Form.php";
			break;
		case "Send":
			$dest = "sendGLitem.php";
			break;
	}


	$ts = sizeof($cba);

	if (!$cba[0])
	{
		$ts = 0;
		$loc = "GroceryList.php";
		header("Location: $loc");
		exit;
	}
	else
	
	

	$loc = $dest . "?func=$val&numchx=$ts&cb=";


	for($i = 0; $i<$ts; $i++)
	{
		sscanf($cba[$i],"chkbox%d",$cbval);
		$loc = $loc . $cbval.","; 
	
	}

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



}



$edit = isset($_POST['edititem']) ? $_POST['edititem'] : false; 

if($edit)
{
	sscanf($edit, "Edit %d", $id);
}
else
{
	$id=$matchID;
}

$connection = dbconnect();
$sql = "select * from groceries where itemid = $id";


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


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>";

//$row = mysql_fetch_array($sql_result);
$row = $sql_result->fetch();
$itemid = $row["itemid"];
$quan = $row["quantity"];
$name = $row["itemname"];
$size = $row["size"];
$units = $row["units"];
$mfctr = $row["manufacturer"];
$notes = $row["notes"];

echo "<input type=\"hidden\" name=\"id\" value=\"$itemid\">";

echo "<TR><TH><input maxlength=\"10\" name=\"Quantity\" value=\"$quan\" size=\"5\"></TH><TH><input maxlength=\"100\" name=\"Name\" value=\"$name\"></TH><TH><input maxlength=\"10\" name=\"Size\" value=\"$size\" size=\"5\"></TH><TH><input maxlength=\"10\" name=\"Units\" value=\"$units\" size=\"5\"></TH><TH><input maxlength=\"100\" name=\"Mfctr\" value=\"$mfctr\"></TH><TH><input maxlength=\"200\" name=\"Notes\" value=\"$notes\"></TH></TR>";

echo "</TABLE>";

echo "<br><input type=\"submit\" name=\"Complete\" value=\"Complete\"><input type=\"submit\" name=\"Complete\" value=\"Cancel\">";

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

?>

</div>

<?php

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

?>

Return current item: Grocery List