|
Posted by Paul on 09/02/06 14:11
mantrid wrote:
> Below are two different ways of writing the same script. The top one works
> but the bottom one displays nothing in the list. Can anyone see why?
>
> <?php
> echo "<select name='subcat' style='WIDTH: 95%'><option value=''>Select
> one</option>";
> while($noticia = mysql_fetch_array($quer)) {
> echo "<option value='$noticia[TopicID]'>$noticia[Topic]</option>";
> }
> echo "</select>";
> ?>
>
>
>
> <select name="subcat" style="WIDTH: 95%">
> <option value="">Select one</option>
> <?php while($noticia = mysql_fetch_array($quer)) { ?>
> <option value="<?php $noticia[TopicID]; ?>"><?php $noticia[Topic];
> ?></option>
> <?php } ?>
> </select>
>
> Ian
Because you're not actually doing anything with that code. HTML isn't a
templating language, you can't just plug values in surrounded by php
tags. you have to actually *do* something with the values. Replace the
4th line with this:
<option value="<?php echo $noticia[TopicID]; ?>"><?php echo
$noticia[Topic]; ?></option>
Cheers,
Paul
Navigation:
[Reply to this message]
|