Dear,
I am making an ordering form and all of the products' data are stored in a MySQL database.
The menu form to select products are all working with plain HTML not php echo's.
But now I can change products' info via a separate web page by updating the MySQL using PHP - more convenient.
From there I can display all 20 items on the menu using PHP's mysql_query:
require('connect.php');
$qty1=$_POST['qty1'];
$qty2=$_POST['qty2'];
//more php code to send to mysql..... (cut out for this)
$getmenu= mysql_query('SELECT * FROM orders WHERE `member`="System"') or die("We've encountered an error:" . mysql_error());
while ($rows3 = mysql_fetch_array($getmenu))
{
$item1=$rows3['qty1'];
$item2=$rows3['qty2'];
$item3=$rows3['qty3'];
$item4=$rows3['qty4'];
$item5=$rows3['qty5'];
//This goes on for 20 products..is there a more efficient way?
//Does this put too much strain on the server?
}
Because of this, I can also filter out the blank items:
<form action="configpizza.php" method="post">
<?php
if($item1!=NULL)
{
echo '<input name="qty1" type="text" class="textfield" id="qty1" />'
echo '//some form elements here...';
}
if($item2!=NULL)
{
echo '<input name="qty2" type="text" class="textfield" id="qty2" />'
echo '// and some more form elements here...';
}
//Now I do this for every item..very tedious and slow!
?>
</form>
Problem:
When I press the submit button it does not send properly to the database. I think it is because it does not process the if statements again so the echoed form parts aren't included... any solutions to this php submitting problem or a more efficient way to deal with all this products?
Remember, this working if I'm using plain html form codes (only good for a small numbers of items) and not the PHP If's.
I hope this makes sense, and I look forward to ideas,
Thanks in advance.