Ok so i an very new to this site and am trying my luck with PHP. Got a great idee to make some cash but now to implement it is a whole new game for me.
I want to keep the selceted value of the select box after the form has been submited with dynamic data from my db(mysql).
i had a look at http://www.daniweb.com/web-development/php/threads/360284/php-keep-dropdown-box-data-after-posting-fails but can't get it to work with my db and site.
my code :
<form action="#" method="post">
<select id="prov" name="prov">
<?php $sql = "SELECT distinct province from escorts ORDER BY province ASC";
$query = mysql_query( $sql );
while( $row = mysql_fetch_assoc($query) )
{
echo "<option value=\"$row[province]\"";
echo "if($_POST['prov']=='$row[province]')";
echo 'selected="selected">'
echo "$row[province]</option>";
}
?>
</select>
<input name="submit" type="submit" value="Select"/>
</form>
I get the folowing error:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/m7593340/public_html/search.php on line 79
Hope this helps