Can some one tell me why the following doesn’t populate the dropdown with the the values from the dist_itnry column of my database?
<?php
$distUsr = $_SESSION['Distributor_user'];
$con=mysql_connect('localhost','root') or die ("Server connection failure!");
$db=mysql_select_db('regional_data',$con) or die ("Couldn't connect the database");
$SQL1="SELECT dist_itnry, route FROM sr_itinerary";
$run1=mysql_query($SQL1,$con) or die ("SQL Error");
$nor1=mysql_num_rows($run1);
while($rec=mysql_fetch_array($run1))
{
while ($rec = $distUsr)
{
echo "<option id='options'>$rec<br></option>";
}
}
?>
You were overwriting
$rec. Also, please take a look at the other changes I made like including the<select>tag and a more proper usage of the<option>tag. You can specify a different value for the<option>tag. Example:<option value="123">Something</option>– this means “123” will be the value submitted when the form is submitted. But “Something” will be displayed in the form.The corrected code is listed below: