Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Please help, drag additional value from mysql

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Please help, drag additional value from mysql

Postby jacquesy » Mon Feb 10, 2003 2:28 pm

Ok, heres the problem.

I have a dropdown list that drags my model names from my database into it:

$Query = "SELECT * FROM model";
$Result = mysql_db_query ($DBName, $Query, $Link);
print ("<form method='get' action='$self'>");

print ("<select name='model' $form_pres>");
print ("<option selected value=''>");

while ($Row = mysql_fetch_array ($Result)) {
print ("<option value='$Row[dbModelName]'>$Row[dbModelName]");
}

print (" <input type='submit' value='select'>");
print ("</form>");


When the model name is selected and the form submitted I want to take an additional value across from the database (dbModelId) using a hidden form element.

How do I do this?? I have thought about it and cannot figure out a solution.

Thanks for you time and help, its much appreciated!

:D :) :( :o :lol: 8) :lol: 8) :x :P :oops: :cry: :wink: :roll: :twisted: :evil: :!: :?: :idea: :arrow:
jacquesy
New php-forum User
New php-forum User
 
Posts: 12
Joined: Tue Jan 21, 2003 2:27 pm

Postby Mixamajic » Mon Feb 10, 2003 10:46 pm

When you set the value of the drop downs make them the ID (dbModelId), and then when you need the Database name use $Query = "SELECT * FROM model where dbModelId = $value" where $value = 'model' $form_pres.

Then the usual query and fetch array.

Code: Select all
$Row = mysql_fetch_array ($Result))


Now you have both the model name and the ID in the $Row[]. I hope this answers your question.
Mixamajic
New php-forum User
New php-forum User
 
Posts: 9
Joined: Sun Feb 02, 2003 6:54 pm
Location: Milwaukee


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.