Location: PHPKode > projects > Grocery List > items.php
<?php
########################################################################
#
# Project: Grocery List
# URL: http://sourceforge.net/projects/grocery-list/
# E-mail: hide@address.com
#
# Copyright: (C) 2010, Neil McNab
# 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/items.php $
# Last Updated: $Date: 2010-03-06 00:03:07 -0800 (Sat, 06 Mar 2010) $
# Author(s): Neil McNab
#
# Description:
#   Manage a list of item in the database.
#
########################################################################

$title = "Item List";

include_once("include/header.php");

$select = $_REQUEST['select'];

$db = dbconnect();

if ($_REQUEST['submit'] == "Delete") {
    $count = 0;
    foreach ($_REQUEST['cb'] as $value) {
        if (!delete_item_by_id($db, $value)) {
            print "<p>ERROR: 100 $count</p>";
        } else {
            $count++;
        }
    }
    print "<p>Deleted $count items.</p>";
}

$result = get_items_with_products($db);

print '<p><a href="edititem.php">Add New Item</a></p>';

print '<form action="">';
print '<p><input type="submit" name="submit" value="Delete" /></p>';
print '<table>';
print '<tr><th>UPC</th><th>Item Brand Name</th><th>Size</th><th>Units</th><th>Generic Product Name</th><th><input name="select" type="submit" value="';
if ($select == "Select All") {
    print "Select None";
} else {
    print "Select All";
}
print '" /></th></tr>';

foreach ($result as $row) {
    print '<tr><td><a href="edititem.php?id=' . $row['itemid'] . '">' . sprintf("%013d", $row['upc']) . '</a></td><td><a href="edititem.php?id=' . $row['itemid'] . '">' . htmlspecialchars($row['itemname']) . '</a></td><td>' . $row['size'] . '</td><td>' . $row['units'] . '</td><td><a href="editproduct.php?id=' . $row['productid'] . '">' . htmlspecialchars($row['productname']) . '</a></td><td><input name="cb[]" value="' . $row['itemid'] . '" type="checkbox"';
    if ($select == "Select All") {
        print ' checked="checked"';
    }
    print ' /></td></tr>';
    print "\n";
}
print '</table>';

print '<p><input type="submit" name="submit" value="Delete" /></p>';
print '</form>';

$db = NULL;

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

?>
Return current item: Grocery List