Re: can't output sql query with php code.
| From: | Paul Goepfert | Date: | Mon, 06 Feb 2006 07:23:09 +0000 |
| Subject: | Re: can't output sql query with php code. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229922@lists.php.net to get a copy of this message | ||
This is the full code for the code that doesn't work.
<?php
echo '<select name="month" >\n';
$month_query = mysql_query("SELECT m_id, months FROM Month");
while ($r = mysql_fetch_array($month_query));
{
$v = $r["m_id"];
$out = $r["months"];
echo "<option value=$v>$out</option>\n";
}
echo '</select>\n';
?>
On 2/6/06, Brady Mitchell <bradym@ext.usu.edu> wrote:
> > Doesn't work
> > -------------------------------------------------
> > <?php
> > $month_query = mysql_query("SELECT m_id, months FROM Month");
> > while ($row = mysql_fetch_array($month_query))
> > {
> > $val = $row["m_id"];
> > $out = $row["months"];
> > echo "<option value=$val>$out</option>";
> > }
> > ?>
>
> You're missing the <select> tags.
>
> > while ($r = mysql_fetch_array($Equip_query))
> > {
> > $val = $r["equip"];
> > echo "<option value=$val>$val</option>\n";
> > }
>
> On a seperate note, if all you are doing with the $val variable is using it to echo, it's
> not needed. Put brackets { } around the var to echo ie: {$r["equip]} - makes it easier to read
> later when you come back to tweak your code.
>
> Brady
>
>
>
>
>
>