I write this code now I want connect 2 list box to each other and when I select an option in first link box, just show its related data in second
please help me
thanks
- Code: Select all
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Select Cities</title>
</head>
<body>
<table>
<tr>
<td colspan=”2″>Religion</TD>
<td>
<select name="items">
<option value="">Choose province</option>
<?
$conn=mysql_connect("127.0.0.1", "university", "123456") ;
mysql_select_db("university",$conn) or die ("error cannot connect");
$sql = "SELECT * FROM province";
$result = mysql_query($sql,$conn) or die(mysql_error());
while ($array = mysql_fetch_array($result)) {
$itemName = $array['provincename'];
$itemcode = $array['provinceno']; ?>
<option value="<?php print($itemcode); ?>"><?=$itemName?>
<?
$sqlt = "SELECT * FROM city
LEFT JOIN province ON city.provinceno = province.provinceno
WHERE `province`.`provinceno` = `city`.`provinceno` AND city.provinceno='$itemcode';
";
?>
<?
} ?>
</select>
</td>
</tr>
<tr>
<td>
<select name="items2">
<option value="">Choose city</option>
<?
$resultt = mysql_query($sqlt,$conn) or die(mysql_error());
while ($array = mysql_fetch_array($resultt)) {
$itemNamet = $array['cityname'];
$itemci = $array['provinceno'];
?>
<option value="<?php print($itemci); ?>"><?=$itemNamet?>
<?
} ?>
</select>
</td></tr>
</table>
</body>
</html>

