Re: Ordering question .....
| From: | Bogdan Stancescu | Date: | Thu, 09 May 2002 16:40:17 +0000 |
| Subject: | Re: Ordering question ..... | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-19086@lists.php.net to get a copy of this message | ||
You could create a form using PHP's great feature of correctly retrieving arrays from POST requests. For example:
---------- page1.php ----------
<form action="page2.php" method="post">
<?
// [connect to db]
$sql="select id, name from stamp order by name";
$result=mysql_run_query($sql);
while ($myrow=mysql_fetch_row($result)) {
echo("<input type=\"hidden\" name=\"ids[]\" value=\"$myrow[0]\">\n");
echo("<input type=\"text\" name=\"quantities[]\">\n");
echo("$myrow[1]<br>\n");
}
?>
<input type="submit">
</form>
-----------
and then walk $_POST["quantities"] using an incrementing index ($i) and for every non-null value of $_POST["quanitites"][$i] you echo whatever you please from the database based on id $_POST["ids"][$i].
HTH
Bogdan
Jim Hatridge wrote:
HI all.. This is my first question to this list. I'm running mysql and SuSE 7.2 with PHP 4. My question: I have a table of stamps to sell (I'm a stamp dealer btw). I want to make a order form with all the items in this table something like this: _________ New Stamp #1 _________ New Stamp #2 And so on thru the table. I want to be able to put a amount in "_____" ie "_____4 New Stamps #1" . Then when I click the submit button PHP will make a new table of only the stamps with an amount in the "_____". Also the number of stamps in the table might (will) change each time I use this form, so I can't say X number of lines. Can someone give me a clue on how to do this? Please keep it simple I'm new to this. Thanks! JIM