I am trying to keep two menu lists' option in variables but i dont know whether to use "selected" or "select name" to assign value

1st one which brings "Student Numbers" rows from its column in selected class table.

$query="SELECT StudentNumber,Student_id FROM $CC";
$result = mysql_query ($query);
echo "<select name=\"STUDENT\" value=''>Student Number</option>";

echo "<option value=$nt[Student_id]>$nt[StudentNumber]</option>";                  
echo "</select>";

and second brings field names (Quizzez and midterms etc..) from that selected class table (btw it piece gives two errors
1-Warning: mysql_list_fields() [function.mysql-list-fields]: Unable to save MySQL query result in
2- Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource

$fields = mysql_list_fields("Courses", "$CC", $link_id2);
$columns = mysql_num_fields($fields);
echo "<select name=\"EXAM\">";
for ($i = 4; $i < $columns; $i++) {
echo "<option value=$i>";
echo mysql_field_name($fields, $i);
echo "</select>";

what should i do in order to assign first one's value to $StudentNumber and second one's $EXAM

To assign the values of the option list you are going to want to use a php echo inside the value quotes:

option value="<?php echo $StudentNumber;?>"
option value="<?php echo $Exam;?>"

When you get the error "Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource", this usually means that your query is wrong so it is not returning any results. Which means your mysql_list_fields is also wrong. The php manual also says that this function is deprecated and shows an alternative to using it. Here is the link to the php manual for mysql_list_fields:

Anyways I hope this was helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.