-1

table design

my code is

<html>
<head>
<body>
<div style="width:400px;height:300px;border:1px solid blue;"> 
<div style="width:400px;height:50px; float: left;">&nbsp;</div>
<form>
<div align="right" style="width:150px;height:30px; float: left;">Show Name :&nbsp;    </div>
<div style="width:250px;height:30px; float: left;">
<select name="show_name" onchange="showUser(this.value)">
<option selected="selected"> -- Select The Show --</option>
<?php   
session_start();
include_once('db.php');
$sql = mysql_query("SELECT show_id, show_name FROM show_name");
while($row=mysql_fetch_array($sql))
{
$show_id = $row['show_id'];
$show_name= $row['show_name'];
echo "<option value ='.$show_id'>$show_name</option>";
}
?>
</select>
</div>
<div align="right" style="width:150px;height:30px; float: left;">Show Place :&nbsp;      </div>
<div style="width:250px;height:30px; float: left;">
<select name="show_place" onchange="showUser(this.value)">
<option selected="selected"> -- Select The Show Place --</option>
<?php   
$sql = mysql_query("SELECT * FROM show_name, show_place WHERE    show_name.show_id=show_place.show_id");
while($row=mysql_fetch_array($sql))
{
$show_id = $row['show_id'];
$show_place = $row['show_place'];
echo "<option value ='.$show_id'>$show_place</option>";
}
?>
</select>
</div>
</form>
</div>
</body>
</head>
</html>

i want to option box condition for stud show to select the particular place .. please guide me how to merge the two table by using if condition or foreach condition

4

1 回答 1

0

对于严格匹配:

    SELECT * 
    FROM show_name
    JOIN show_place ON (show_name.show_id = show_place.show_id)

或者,如果您也想要没有地方的名称:

    SELECT * 
    FROM show_name
    LEFT JOIN show_place ON (show_name.show_id = show_place.show_id)
于 2013-04-25T11:18:56.357 回答