July 24th, 2000, 05:43 PM
I am working on a site that is going to be listing diners in my town and local cities. I have been reading up the tutorial on the webmasterbase.com site with PHP and mysql. Well I have been going thru that pretty good. But I have one question. How would i setup a pulldown menu so that when you would say select munster it would go to the database and pull the information out of the database and put it on the page.
I am not clear with the way to set up the pulldown menu. I know how i could do this with just a standard link but not a pulldown menu. Thank you for your help in advance.
July 24th, 2000, 06:21 PM
This assumes you have a table in a database like this with data in it:
CREATE TABLE info (
ID INTEGER NOT NULL AUTO_INCREMENT,
Put following in say index.php3. Normally doesn't work in a .html file. Must end with .php , .php3 etc. depending on server configs.
Then to retrieve it in a select drop down:
// $mysql_link = connection stuff varies. Only need to connect one time for the whole script so you may want to put this at the beginning of the page instead with <?php $mysql_link = connect_to_database functions etc. php?>.
inside index.php3 put:
<form action="somefile.php3" action="GET">
<option selected>- Select Something -</option>
// For Select
$query = "SELECT * FROM info ORDER BY title";
$result = mysql_query($query, $mysql_link);
Then the $mySelectVariable will be passed to somefile.php3 with the value of ID from the database
Usage of database functions vary.
That's about it.