How to Join tree queries??

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
aris1234
Forum Newbie
Posts: 11
Joined: Mon May 07, 2007 7:10 am

How to Join tree queries??

Post by aris1234 »

How to Join tree queries?? (select multiple table)

this code for searching in my page

Code: Select all

$coachs	= $_GET["coachs"];
$dates	= $_GET["dates"];
1st query

Code: Select all

$query 	= mysql_query("SELECT * FROM table1 WHERE s_coach='$coachs' AND s_date='$dates' ORDER BY s_time ASC ") or die(mysql_error());
	$result	= mysql_numrows($query);
2nd query

Code: Select all

$query 	= mysql_query("SELECT * FROM table2 WHERE s_coach='$coachs' AND s_date='$dates' ORDER BY s_time ASC ") or die(mysql_error());
	$result	= mysql_numrows($query);
3th query

Code: Select all

$query 	= mysql_query("SELECT * FROM table3 WHERE s_coach='$coachs' AND s_date='$dates' ORDER BY s_time ASC ") or die(mysql_error());
	$result	= mysql_numrows($query);
looping here

Code: Select all

<?php 
	if($row = mysql_fetch_array($query))
		{
          do
		{
			?>

<table>
      <tr>
           <td>
                 <form>
                         <input type="text" name="sta" value="<?php echo $row["student1"] ?>" />
                          <input type="text" name="t1" value="<?php echo $row["s_time"] ?>" />
    	                 <input type="text" name="sdate" value="<?php echo $row["s_date"] ?>" />
    	                 <input type="text" name="ncoach" value="<?php echo $row["s_coach"] ?>" />
                         <input type="submit" value="submit">
                </form>
          </td>
           <td>
                   <form>
                         <input type="text" name="sta" value="<?php echo $row["student2"] ?>" />
                          <input type="text" name="t1" value="<?php echo $row["s_time"] ?>" />
    	                 <input type="text" name="sdate" value="<?php echo $row["s_date"] ?>" />
    	                 <input type="text" name="ncoach" value="<?php echo $row["s_coach"] ?>" />
                         <input type="submit" value="submit">
                </form>   
           </td>      
            <td>
                   <form>
                         <input type="text" name="sta" value="<?php echo $row["student2"] ?>" />
                          <input type="text" name="t1" value="<?php echo $row["s_time"] ?>" />
    	                 <input type="text" name="sdate" value="<?php echo $row["s_date"] ?>" />
    	                 <input type="text" name="ncoach" value="<?php echo $row["s_coach"] ?>" />
                         <input type="submit" value="submit">
                </form>   
           </td>      
</tr>
</table>

<?php }
    while ($row = mysql_fetch_array($query));
    echo "</td>";
	} else {
	echo "no data"	
}
 ?>

how code for multiple queries ?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

you said it in the subject: "How to JOIN" :)
Post Reply