echo ( "<input type=\"radio\" name=\"ledger_acct\" value=\"" . $row["acct"] . "\">" . $row["descript"] . "<br>\n";
David Jackson wrote:
OK, this works but there has to be a pretty way? John, I'm not sure what you mean about the while loop?David ------------- Works ------------------------- <html> <head><title>Operation Sticky Bun</title></head <body> <h3 align="center">Operation Sticky Bun </h3> <?php require('connect.php'); ?> <?php print '<form action="hello.php" method="post">'; $header = mysql_query ("SELECT * FROM chart ORDER BY acct "); if ($row = mysql_fetch_array($header)) { do { print '<input type="radio" name="ledger_acct" value="'; print $row["acct"];print '">'; print $row["descript"];print '<br>'; } while($row = mysql_fetch_array($header)); } else {print "Sorry, no records were found!";} print '</form>'; ?> </body> </html> Rija wrote:oups ... you're right ! ----- Original Message ----- From: "John Nichel" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: "php" <[EMAIL PROTECTED]>; "David Jackson" <[EMAIL PROTECTED]> Sent: Monday, November 04, 2002 2:57 PM Subject: Re: [PHP] radio buttons from MySQL query?There is no reason to put brackets behind the name of the radio element.
The brackets are neccessary for multi-select elements like checkboxes, but
radio buttone are a single select element.
Your if statement should be a while loop.
I'm sure you don't want to set this ( value=acct[] ) as the value for each
radio button. Do it that way, and no matter which one is picked, it will be
the same value.
rija wrote:I don't think so, Put the bracket with your radio's name not with your the value/// For example : print "<td width=2><input type=radio name=gl_acct[] value=$row['acct']>{$row['acct']}</td>" ... and so one/ ----- Original Message ----- From: "David Jackson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 04, 2002 1:15 PM Subject: [PHP] radio buttons from MySQL query?How do I go about building radio buttons using the results of a MySQL query. The record layout looks like this: acct cat description I want to use acct as the value="acct" in the input statement for the radio box. The code below almost works? TIA, David <?php $header = mysql_query ("SELECT * FROM chart ORDER BY acct "); if ($row = mysql_fetch_array($header)) { do { print("<tr bgcolor=\"white\" >"); print '<td width="5"><input type="radio" name="gl_acct" value=acct[]"></td>'; print("<td width=\"12\">"); print $row["acct"]; print "</td><td width=\"12\">"; print $row["cat"]; print "</td><td >"; print $row["descript"]; print("</td></tr>\n"); } while($row = mysql_fetch_array($header)); } else {print "Sorry, no records were found!";} ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php