Please Help with LOOP!!
| From: | Wee Keat | Date: | Fri, 19 Jul 2002 00:36:40 +0000 |
| Subject: | Please Help with LOOP!! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108358@lists.php.net to get a copy of this message | ||
Hi all...
I'm a complete beginner in programming. Just started a few months ago.
So, I'm sorry if this is a stupid question to ask. But I'm at a dead end here and do not
know where else to go.
I'm trying to automate a checkbox name to have the name "choice1" to have incremental
effect on the number such as the following:
<input type="checkbox" name="choice1" value="x">
<input type="checkbox" name="choice2" value="x">
<input type="checkbox" name="choice3" value="x">
...
And I used the following script (please don't laugh) :)
Maximise this email to full screen so that you can see the script better.
for($count=1; $count<=$rows; $count++) {
while($query_data = mysql_fetch_array($result)) {
$price = $query_data["price_lq"];
$RowColor = useColor();
echo "<TR BGCOLOR=\"$RowColor\">\n";
echo "<TD width=\"10%\" valign=\"top\"><font
size=\"2\" face=\"Arial, Helvetica,
sans-serif\">",$query_data["prod_brand"],"<BR></FONT</TD>";
echo "<TD width=\"60%\" valign=\"top\"><font
size=\"2\" face=\"Arial, Helvetica,
sans-serif\">",$query_data["prod_desc"],"<BR></FONT></TD>";
echo "<TD width=\"15%\" valign=\"top\<font size=\"2\"
face=\"Arial, Helvetica,
sans-serif\">","$",$price,"<BR></FONT></TD>";
echo "<TD width=\"15%\" valign=\"top\"><input
type=\"checkbox\" name=\"choice",$count,"\" value=\"",
$query_data["prod_id"],"\"></TD>\n</TR>";
}
}
The result was irritating... it came up with the same name, which is "choice1" all the way
like:
<input type="checkbox" name="choice1" value="x">
<input type="checkbox" name="choice1" value="x">
<input type="checkbox" name="choice1" value="x">
...
Am I doing it the wrong way? If so, how should I do it?
Please pleas help... thanks
Yours,
Wee Keat
------------------------------------------------------------
"Good timber does not grow with ease; the stronger the wind, the stronger the trees."