You are here: Re: html within php works, but php within html doesnt « PHP Programming Language « IT news, forums, messages
Re: html within php works, but php within html doesnt

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация