Jump to content

dynamic list to select certain data from db


pumaf1

Recommended Posts

hi,

my second question -

on my website i am programming a interactive db, please see http://www.pumaf1.org.uk/res/infobase/search.php to see what i mean

 

want i would like to do is the following -

 

grab data to build the "drivers" drop down list from the db - done (as you can see)

from that list enable a user to click on the driver name and go to a page for that driver that pulls out all the results for that one driver.

 

thats the problem. for example you click on "raikkonen, kimi", and you get the url

 

http://www.pumaf1.org.uk/res/infobase/Raikkonen,%20Kimi

 

now what i am TRYING to do is

 

have a page that you load the results page http://www.pumaf1.org.uk/res/infobase/search.php select your driver, and it would pull out every race result for that driver. That driver will have more than one result in the db so it needs to be a repeat region

 

I am using dreamweaver mx 2004, and am really stuck. Please be aware I am only learning PHP and MYSQL so please make it easy if you can.

 

you can see what I would expect (albeit for engines output)(there will be more than one drop down list when its finished)

 

www.pumaf1.org.uk/res/infobase/engine-ferrari.php

 

of course anyone that helps me with this will get a mention in the credits section of the site if they so wish

 

 

thanks in advance

 

Dave

Link to comment
Share on other sites

this is what i made to create a dynamic drop down list from a database all you would have to do is change the mysql query to suit your needs dont know if this heps anyway whilst writing this i can smell  burning and about to run for the extinguisher for my computer hope this helps i might not be able to reply

<?php
$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name=""; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

echo'<select name="categories">';

$res=mysql_query("select * from $tbl_name");
if(mysql_num_rows($res)==0) echo "there is no data in table..";
else
for($i=0;$i<mysql_num_rows($res);$i++) {
$row=mysql_fetch_assoc($res);
echo"<option>$row[userid]</option>";
}
echo'</select>';
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.