how to retrieve the data from two table in mysql database with if condition in php mysql -
my code
<html> <head> <body> <div style="width:400px;height:300px;border:1px solid blue;"> <div style="width:400px;height:50px; float: left;"> </div> <form> <div align="right" style="width:150px;height:30px; float: left;">show name : </div> <div style="width:250px;height:30px; float: left;"> <select name="show_name" onchange="showuser(this.value)"> <option selected="selected"> -- select show --</option> <?php session_start(); include_once('db.php'); $sql = mysql_query("select show_id, show_name 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 : </div> <div style="width:250px;height:30px; float: left;"> <select name="show_place" onchange="showuser(this.value)"> <option selected="selected"> -- select show place --</option> <?php $sql = mysql_query("select * show_name, show_place 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 option box condition stud show select particular place .. please guide me how merge 2 table using if condition or foreach condition
for strict matches:
select * show_name join show_place on (show_name.show_id = show_place.show_id)
or if want names without places too:
select * show_name left join show_place on (show_name.show_id = show_place.show_id)