Location: PHPKode > scripts > Shopping Cart - Shopping list application > shopping-cart-shopping-list-application/editshop.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">

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

	<body bgcolor="#bab9f8">
	<? include "config.php"; 

$shop=$_REQUEST["shop"];
$oldshop=$_REQUEST["oldshop"];
$save=$_REQUEST["save"];
$name=$_REQUEST["name"];
$new=$_REQUEST["Add"];
$del=$_REQUEST["Delete"];

if ($save!="" && $shop=$oldshop) {
	$q="update shop set name=\"$name\" where shop=$shop";
	mysql_query($q);
	}

if ($new!="") {
	$q="insert into shop values (0,\"$name\")";
	mysql_query($q);
	$shop=mysql_insert_id();
	print "Shop created<br>";
	}

if ($del!="") {
	$q="delete from shop where shop=$shop";
	mysql_query($q);
	print "Shop deleted<br>";
	$q="update item set shop=0 where shop=$shop";
	$r=mysql_query($q);
	$n= mysql_affected_rows();
	print "$n items moved<br>";
	}

?>


		<form id="EditShop" action="editshop.php" method="post" name="EditShop">
			<table width="100%" border="0" cellspacing="2" cellpadding="0">
				<tr>
					<th>Edit Shop:</th>
					<td><select name="shop" size="1" onchange="submit()">
							<? $q="select * from shop order by name,shop";
							$r=mysql_query($q);
							$n=mysql_num_rows($r);
							for ($t=1;$t<=$n;$t++) {
								$data=mysql_fetch_row($r);
								print "<option ";
								if ($shop==$data[0]) {
									print "selected=\"selected\"";
									$sel=$data;
								}
								print "value=\"$data[0]\">$data[1]</option>\n";
							}
							?>
						</select><input type="submit" name="edit" value="Go" /> <input type="hidden" name="oldshop" value="<? print $shop; ?>" /></td>
				</tr>
				<tr>
					<td align="right">Shop:</td>
					<td><input type="text" name="name" value="<? print $sel[1] ?>" size="24" /></td>
				</tr>

				<tr>
					<th align="center"><a href="index.php">Back</a></th>
					<td><input type="submit" name="save" value="Change" /><input type="submit" name="Add" value="New" /><input type="submit" name="Delete" value="Del" /></td>
				</tr>
			</table>
		</form>
		<p></p>
	</body>

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