Can I put php inside html that is inside php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CraneVallon
Forum Newbie
Posts: 1
Joined: Tue Feb 09, 2010 10:13 am

Can I put php inside html that is inside php?

Post by CraneVallon »

On my user form I want a select option from a list that is built new each time from the contents of the database. Therefore I open php to find the list of row contents (I'm using the column called 'team'), then I tell the html to display a list of these elements in the select option. That's okay, say the team in the third row is Brighton then the third select option is Brighton. But I also need to individually name that third value in order to return it through POST for processing. In other words, I can't get the html to accept the value of the item. Here's my code (the html select name multiple etc are outside this block):

$result = mysql_query("SELECT * FROM assoTel");
while ($row = mysql_fetch_array($result))
{
echo "<
option value=\"
<?php
echo $row['name'];
?>
\"
>"
.$row['name']."</option><br/>";
}
mysql_free_result($result);
jefffan24
Forum Commoner
Posts: 72
Joined: Mon Nov 02, 2009 8:18 am

Re: Can I put php inside html that is inside php?

Post by jefffan24 »

echo "<option value=" . $row['name'] . "continue your html";

Make sure you close your quotations put a . then put your php put another . then open your quotations and continue like nothing happened :D
Post Reply