Hi, This is my first time here in the forum. i hope i will get some help. Here is my code $results_id = @mysql_query($query, $connect) or die('query error: ' . mysql_error()); print '<select name=\"studentid"\>'; while($row = mysql_fetch_row($results_id)); { $count1=count($row); for($i=0; $i<=count1; $i=$i+1) { print '$row[$i]'; } } print '</select>'; I am kinds new to php and i dont know what wron did i do in the code above . i wanted to create a dropdown list form the values in a table in a database. lets say table name: student that has student id and student name I have no freaking idea how to do it. Your help will be appreciated
I'll give you a hint. Look at the HTML source for a working drop down box. Compare that to the output your code has. You're really close just missing a couple of tags.
$results_id = @mysql_query($query, $connect); echo "<select name=\"studentid\">"; while($row = mysql_fetch_row($results_id)); { echo "<option value=\"".$row['id']."\">".$row['student_name']."</option>"; } echo "</select>";
echo "<select name=\"studentid\">"; while($row = mysql_fetch_row($results_id)); { echo "<option value=\"".$row['stu_id']."\">".$row['stu_id']."</option>"; } echo "</select>"; print '</select>'; In above code i am trying to create a drop down list from a data in a table in a database The name of the field in table is stu_id Please help I really need your help