Location: PHPKode > scripts > Shopping Cart - Shopping list application > shopping-cart-shopping-list-application/index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<? include "config.php"; 
$snum=$_REQUEST["snum"];
$allprod=$_REQUEST["allprod"];
$oldall=$_REQUEST["oldall"];
$oldsnum=$_REQUEST["oldsnum"];

$col[0]="#fff4cf";
$col[1]="#e4d090";

?>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
		<title>Shopping</title>
	</head>

	<body bgcolor="#bab9f8">
		<form action="index.php" method="post" name="shop">
			<table width="100%" border="0" cellspacing="2" cellpadding="0" bgcolor="#bab9f8">
				<tr>
					<th colspan="2">Shopping   <font size="-1">    </font><select name="snum" size="1" onchange="submit()">
							<option <? if ($snum==0 || $snum=="") print "selected=\"selected\""; ?> value="0">all</option>
<?
							$q="select * from shop order by name";
							$r=mysql_query($q);
							$n=mysql_num_rows($r);
							for ($t=1;$t<=$n;$t++) {
								$data=mysql_fetch_row($r);
								print "<option ";
								if ($snum==$data[0]) print "selected=\"selected\"";
								print "value=\"$data[0]\">$data[1]</option>\n";
							}
?>
						</select> <input type="hidden" name="oldall" value="<? print $allprod; ?>" /><input type="hidden" name="oldsnum" value="<? print $snum; ?>" />
<input type="checkbox" name="allprod" value="1" <? if ($allprod==1) print "checked=\"checked\"" ?> onchange="submit()"/> All <input type="submit" name="update" value="Go" /></th>
				</tr>
<?
				$q="select * from item where 1=1 ";
				if ($snum>0) {
					if ($allprod==1)
						$q=$q . "and shop=$snum ";
					else
						$q=$q . "and (shop=$snum or shop=0) ";
				}
				if ($allprod==0 || $allprod=="") $q=$q . "and buy=1";
				$q=$q . " order by isle,product";
				$r=mysql_query($q);
				$n=mysql_num_rows($r);
				$c=1;
				for ($t=0;$t<$n;$t++) {
					$data=mysql_fetch_row($r);
					if ($allprod==1 && $oldall==$allprod && $snum==$oldsnum) {	// Einkaufsliste erstellen - alles wird angezeigt
						$i="item".$data[0];
						$sel=$_REQUEST[$i];
						if ($sel=="") $sel=0;
						if ($sel!=$data[6]) {	// Datenbank updaten
							mysql_query("update item set buy=$sel where id=$data[0]");
							$data[6]=$sel;
						}
					}
					if ($allprod==0 && $oldall==$allprod && $snum==$oldsnum) {	// Einkaufsliste erstellen - alles wird angezeigt
						$i="item".$data[0];
						$sel=$_REQUEST[$i];
						if ($sel=="") $sel=0;
						if ($sel==1) {	// Datenbank updaten
							mysql_query("update item set buy=0 where id=$data[0]");
							continue;
						}
					}

					print "<tr bgcolor=\"" . $col[$c] . "\">\n";
					print "<th width=10><input type=checkbox name=\"item" . $data[0] . "\" value=1 onchange=\"submit()\" ";
					if ($allprod^$data[6]==0) {
						print "checked=\"checked\" ";
					}
					print "/></th>\n";
					print "<td><a href=\"edititem.php?item=$data[0]\">" . $data[1] . "</a>";
					if ($data[7]!=0) print " (" . money_format('%i',$data[7]) . ")";
					print "</td>";
					print "</tr>\n";
					$c=1-$c;
				}
				?>
				<tr>
					<td colspan="2" align="center"><input type="submit" name="update" value="Update" /></td>
				</tr>
				<tr>
					<td colspan="2" align="center"><font size="-2">(C) 2006 G.Glendown</font></td>
				</tr>
			</table>
		</form>
		<p></p>
	</body>

</html>
Return current item: Shopping Cart - Shopping list application