<?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/printGLitem.php $
# Last Updated: $Date: 2010-03-06 00:03:07 -0800 (Sat, 06 Mar 2010) $
# Author(s): James Campbell
#
########################################################################
$title = 'Print';
include_once("include/header.php");
?>
<body>
<?php
$colitemid = isset($_GET["colitemid"]) ? $_GET["colitemid"] : "";
$colquantity = isset($_GET["colquantity"]) ? $_GET["colquantity"] : "";
$colname = isset($_GET["colname"]) ? $_GET["colname"] : "";
$colsize = isset($_GET["colsize"]) ? $_GET["colsize"] : "";
$colmfctr = isset($_GET["colmfctr"]) ? $_GET["colmfctr"] : "";
$colnotes = isset($_GET["colnotes"]) ? $_GET["colnotes"] : "";
$coltimeadded = isset($_GET["coltimeadded"]) ? $_GET["coltimeadded"] : "";
$smalltext = isset($_GET["smalltext"]) ? $_GET["smalltext"] : "";
$table = isset($_GET["table"]) ? $_GET["table"] : "";
$confirm = isset($_GET["confirm"]) ? $_GET["confirm"] : "";
$ids = isset($_GET["ids"]) ? $_GET["ids"] : "";
$numchx = isset($_GET["numchx"]) ? $_GET["numchx"] : "";
echo "<center>";
echo "Grocery List ";
echo date("m-d-Y");
echo "<br>";
if($smalltext == "1")
{
echo "<small><small>";
}
if ($confirm=="Cancel")
{
$loc = "GroceryList.php";
header("Location: $loc");
exit;
}
$ida = $ids;
$connection = dbconnect();
if($table == NULL)
{
$start = 0;
for($i = 0; $i<$numchx; $i++)
{
$end = strpos($ida, " ", $start);
$id = substr($ida, $start, $end-$start);
$start = $end+1;
$sql = "select * from groceries where itemid = $id";
//echo $sql;
//$sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");
$sql_result = $connection->query($sql);
// $row = mysql_fetch_array($sql_result);
$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($colitemid == "1")
{
echo "$extitemid ";
}
if($colquantity == "1")
{
echo "$extquan ";
}
if($colname == "1")
{
echo "$extname ";
}
if($colsize == "1")
{
echo "$extsize $extunits ";
}
if($colmfctr == "1")
{
echo "$extmfctr ";
}
if($colnotes == "1")
{
echo "$extnotes ";
}
if($coltimeadded == "1")
{
echo "$exttime";
}
echo "<br>";
// mysql_free_result($sql_result);
}
//mysql_close($connection);
$connection = NULL;
}
else
{
echo "<TABLE BORDER=1 align=\"center\">";
echo "<TR>";
if($colitemid == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "Item ID";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colquantity == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "Quantity";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colname == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "Name";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colsize == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "Size";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colmfctr == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "Mfctr";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colnotes == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "Notes";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($coltimeadded == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "Time Added";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
echo "</TR>";
$start = 0;
for($i = 0; $i<$numchx; $i++)
{
$end = strpos($ida, " ", $start);
$id = substr($ida, $start, $end-$start);
$start = $end+1;
$sql = "select * from groceries where itemid = $id";
//echo $sql;
//$sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");
//$row = mysql_fetch_array($sql_result);
$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"];
echo "<TR>";
if($colitemid == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "$extitemid";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colquantity == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "$extquan";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colname == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "$extname";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colsize == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "$extsize $extunits";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colmfctr == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "$extmfctr";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($colnotes == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "$extnotes";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
if($coltimeadded == "1")
{
echo "<TH>";
if($smalltext == "1")
{
echo "<small><small>";
}
echo "$exttime";
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</TH>";
}
echo "</TR>";
//mysql_free_result($sql_result);
}
echo "</table>";
//mysql_close($connection);
$connection = NULL;
}
if($smalltext == "1")
{
echo "</small></small>";
}
echo "</center>";
include_once($WEBROOT . "/include/footer.php");
?>