Hi there, took ages to understand how to get this far!!! Looking to see if anybody has any way of helping me with the following.
I have two tables:
clients (client_id, client_name)
location (client_id, client_site_name)
The drop down for the clients I have already written in the code below. I have the logical solution in my head already and all the conditions that need to be met for the second drop down to work.....
Trying to make this work in PHP is driving me nuts.....just doesn't seem to work the same way as programming in basic! (understandably!)
Any help with this would be great, I could then get on and create all the other drop downs for the sections......
Cheers!
code so far:
CONFIG.INC.PHP
<?php
// Variables for the connection
$dbserver="localhost";
$dbusername="root";
$dbpassword="password";
$dbtablename="clients";
$db="fixitsupport";
?>
***************************DBCONNECT.INC.PHP
<?
include_once ("config.inc.php"); ?>
<?php
// This will connect to the database or return an error
// String containing the mysql connection command
$dbconnect = @mysql_connect($dbserver, $dbusername, $dbpassword) or die (mysql_error());
// Command to connect to the database
mysql_select_db($db, $dbconnect) or die (mysql_error);
?>
**********************DROPDOWN.PHP
<?
// Include the Database connection script
include_once ('dbconnect.inc.php');
// Perform the mysql query on the clients table
$link = mysql_connect ($dbserver, $dbusername, $dbpassword);
$query = "Select client_name from $dbtablename order by client_name";
$results = mysql_db_query($db, $query, $link);
?>
Which Client would you like to select?
<select name = "clientdropdownselection" size="1">
<Option Value=" ">Select One:</option>
<? //Begins PHP
for($u=0;$u<mysql_num_rows($results); $u++) {
$client=mysql_result($results,$u,'client_name');
?>
<option value="<? echo($client); ?>"><? echo($client); ?></option>
<? //Begins PHP
}
?>
</select>
<form method=post action="pagetolinkto.php">
<input type=submit value="Next">
</form>
help with double drop down menu populated from mysql please!
Moderator: General Moderators