<html>
 <head>
  <title>New Customer Setup</title>
  <link type="text/css" rel="stylesheet" href="style.css" />
 </head>
 <body>

  <? 
@

mysql_connect($hostname,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM Pizza";
$result=mysql_query($query);
$num=mysql_numrows($result);


//good practice to close the database
mysql_close();
?>

<table border="0" cellspacing="2" cellpadding="2">
	<tr>
		<th>INDEX</th>
		<th>Name of Pizza</th>
		<th>Discription</th>
		<th>MPrice</th>
		<th>LPrice</th>
		<th>XLPrice</th>
	</tr>
<?
$i=0;
	while ($i < $num) 
	{
		$NamePizza=mysql_result($result,$i,"Name");
		$Discription=mysql_result($result,$i,"Discription");
		$MPRICE=mysql_result($result,$i,"MPrice");
		$LPRICE=mysql_result($result,$i,"LPrice");
		$XLPRICE=mysql_result($result,$i,"XLPrice");
?>
	<tr>
		<th><?echo $i+1?></th>
		<th><? echo $NamePizza; ?></th>
		<th><? echo $Discription; ?></th>
		<th><? echo $MPRICE; ?></th>
		<th><? echo $LPRICE; ?></th>
		<th><? echo $XLPRICE; ?></th>
	</tr>

<?
		$i++;
	}
echo "</table>";
?>
<form method="post">
<input type="text" name="IndexVal" value=<? echo $_POST['IndexVal'];?>><br><input type="submit" name="showchanges" value="Edit this value">
</form>

<? 
$i=$_POST['IndexVal'];
		$NamePizza=mysql_result($result,$i,"Name");
		$Discription=mysql_result($result,$i,"Discription");
		$MPRICE=mysql_result($result,$i,"MPrice");
		$LPRICE=mysql_result($result,$i,"LPrice");
		$XLPRICE=mysql_result($result,$i,"XLPrice");
if ($showchanges){?>
<form action="changedb.php" method="post">
Name of Pizza:  <br><input type="text" name="NamePizza" value="<? echo $NamePizza;?>"><br>
Discription: 		<br><input type="text" name="Discription" value="<? echo $Discription;?>"><br>
MPrice:   			<br><input type="text" name="MPRICE" value="<? echo $MPRICE;?>"><br>
LPrice:					<br><input type="text" name="LPRICE" value="<? echo $LPRICE;?>"><br>
XLPrice:    		<br><input type="text" name="XLPRICE" value="<? echo $XLPRICE;?>"><br>
<input value="Save" type="Submit">
<INPUT value="Start Over" type="reset">
</form>
<?}?>
