Hi all,
I'm pretty new to PHP, and I'm stuck.
Basically I'm trying to setup a page where records can be edited etc. So I've basically got it working except for a drop down select list. What happens is that on the first record the drop-down box works fine, however the loop seems to stop then and all I get is a blank drop-down box on the following records.
I hope people can see what I am trying to do.
if ($edit=="true") {
$catSql = "SELECT * FROM menu_cat";
$catResult = mysql_query($catSql);
$catArray = mysql_fetch_array($catResult);
$editSql = "SELECT * FROM menu";
$editResult = mysql_query($editSql);
$editArray = mysql_fetch_array($editResult);
do {
echo "<hr>\n<form action=\"$PHP_SELF?edit=submit\" method=\"get\">\n";
echo "<p>Item Name: <input name=\"menuItem\" type=\"text\" value=\"$editArray[menuItem]\">\n";
echo "<p>Menu Category: <select name=\"menuCat\" value=\"$editArray[menuCat]\">\n";
do {
echo "<option value=\"$catArray[catType]\">$catArray[catType]</option>\n";
} while ($catArray = (mysql_fetch_array($catResult)));
echo "</select>";
echo "<p> Description: <textarea name=\"itemDesc\" cols=\"\" rows=\"3\">$editArray[itemDesc]</textarea>\n";
echo "<p>Price: (ie 20.00) <input name=\"price\" type=\"text\" value=\"$editArray[price]\">\n";
echo "<p><input name=\"update\" type=\"submit\" value=\"update\">\n";
echo "<p><input name=\"delete\" type=\"submit\" value=\"delete\">\n";
echo "</form>";
} while ($editArray = (mysql_fetch_array($editResult)));
}
Also I see a lot of people using just while instead of do..while. However, when I try to use that the first result from the query is always dropped off, is that normal?
Thanks in advance.