| | |
How to assign Menu lists' values to variables?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2009
Posts: 4
Reputation:
Solved Threads: 0
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.
what should i do in order to assign first one's value to $StudentNumber and second one's $EXAM
1st one which brings "Student Numbers" rows from its column in selected class table.
php Syntax (Toggle Plain Text)
$query="SELECT StudentNumber,Student_id FROM $CC"; $result = mysql_query ($query); echo "<select name=\"STUDENT\" value=''>Student Number</option>"; while($nt=mysql_fetch_array($result)){ 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
Last edited by peter_budo; Jan 6th, 2009 at 2:01 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
To assign the values of the option list you are going to want to use a php echo inside the value quotes:
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:
http://us.php.net/mysql_list_fields
Anyways I hope this was helpful.
PHP Syntax (Toggle Plain Text)
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:
http://us.php.net/mysql_list_fields
Anyways I hope this was helpful.
A little clarification goes a long way.
![]() |
Other Threads in the PHP Forum
- Previous Thread: Foreign Key is different than primary key
- Next Thread: How can one upload multiple files with php?
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop parse paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source space speed sql structure subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web white xml youtube





