Hello,
I have a MySQL database and I'm trying to make a dropdown list using PHP based on the value stored in my DB.
So far I have this (copied, pasted, and edited from another forum):
<form action="maintest2.php" method="POST">
<table border="0" cellpadding="2" width="100%">
<tr>
<td><b>Main Category:</b></td>
<td>
<select name="Name">
<option value="0">Select Country
<?php
include 'config.php';
include 'opendb.php';
$cate = mysql_result($result, 0);
$result=mysql_query("SELECT c.`Name` FROM clientconfiguration.country c ORDER BY `Name`") or exit
(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
echo '<option value="' . $row['Name'] . '"';
if ($row['Name'] == $cate) {echo ' selected';} echo '>' . $row['Name'];
}
include 'closedb.php';
?>
</select>
</td>
</tr>
<tr><td colspan=2><input type="submit" name="submit" value="submit"></td></tr>
</table>
</form>
It does show the name of the countries I want, but i don't know how to move on from here.
I want a second dropdown list based on the query:
SELECT cl.`Name`
FROM `client` cl, country co
WHERE co.`Country ID` = cl.`Country ID`
AND co.`Name` = 'Whatever the value is selected from the first dropdown list';
And then below the second dropdown list there will be 3 fixed option:
Production, DR, Test
And based on the 2nd and 3rd option i need to run this query:
SELECT sy.`Label`
FROM `system` sy, `environment` en, `client` cl, `environmenttype` ent
WHERE cl.`Client ID` = en.`client ID`
AND en.`Environment ID` = sy.`Environment ID`
AND ent.`ID` = en.`Type`
AND cl.`Name` = 'drop down list 2 value'
AND ent.`Type` = '3rd option selection';
and finally a two-columned box to view the final result:
SELECT pd.`Name`, vd.`Version`
FROM `system` sy, `product` pd, `versiondetail` vd
WHERE vd.`System ID` = sy.`System ID`
AND vd.`Product ID` = pd.`Product ID`
AND sy.`Label` = 'the above query's selection';
I don't expect anyone to write me the whole code (tho that'll be awesome) but even a small help on this will be great! Been browsing different forums for some clue for 3 days but I'm really lost now!
Tobie.