to write php variable in html option tag -
i want write php variable within html alternative tag, code not working.
<html> <body> <?php $host="localhost" ; $mysql_db="db" ; $mysql_u="root" ; $mysql_p="" ; mysql_connect( "$host", "$mysql_u", "$mysql_p"); mysql_select_db( "$mysql_db"); $sel="select * site" ; $val=mysql_query($sel); while($row=m ysql_fetch_array($val, mysql_assoc)) { $a=$row[ 'a']; <option value="$a" name="a">$a</option> } ?> </body> </html>
i saved file in .html extn right?
you should echo it:
echo '<option value="'.$a.'" name="a">'.$a.'</option>';
and concatenate vars.
also, don't utilize mysql extension, either utilize mysqli or pdo extensions , prepared statements. here's why: why shouldn't utilize mysql_* functions in php?.
php html
No comments:
Post a Comment