Page 1 of 1

How to Join tree queries??

Posted: Mon Jul 30, 2007 2:40 am
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 ?

Posted: Mon Jul 30, 2007 3:13 am
by aceconcepts

Posted: Mon Jul 30, 2007 4:33 am
by miro_igov
you said it in the subject: "How to JOIN" :)