onthespot Posted August 13, 2009 Share Posted August 13, 2009 Hey guys. My code is designed to take the comp_name field from table COMPETITIONS and check the FIXTURES table field COMP for any fixtures where the comp field is the same as comp_name from competitions table and also where the user is the home or away user in the fixtures table. If rows are found, then the idea is for whatever row is found to be displayed on the fixtures.php page. The following is my code so far. <?php // select all league competitions $competition = ("SELECT `comp` FROM `competitions` WHERE `comp_type` = 'league' "); // user for this part of competition on site $user = $_SESSION['username']; // take the competitions and check if there are any fixtures in the fixture table with this name $comp = mysql_query("SELECT `comp` FROM `fixtures` WHERE `comp` = '$competitions' AND `home_user` = '$user' OR `away_user` = '$user' "); $num_rows = mysql_num_rows($comp); // if there are, select them from the competitions table and display if ($num_rows > 0) { $leagues = mysql_query("SELECT `comp_name`, `game`, `format` FROM `competitions` WHERE `comp_type` = 'league' AND `comp_name` = '$competition'"); echo"<table cellspacing=\"10\"> <tr> <td>Competition</td> <td>Game</td> <td>Format</td> </tr>"; while( $row = mysql_fetch_assoc($leagues)) { extract($row); $info = explode("_",$row[comp_name]); echo" <tr> <td><A HREF='leaguefix.php?comp=$comp_name'>$info[2]</A></td> <td>$info[1]</td> <td>$info[0]</td> </tr>"; } echo"</table>"; echo mysql_error(); } else { } ?> mysql_num_rows isnt working? Link to comment https://forums.phpfreaks.com/topic/170154-crossing-two-tables/ Share on other sites More sharing options...
onthespot Posted August 13, 2009 Author Share Posted August 13, 2009 I only want it to display the leagues that have fixtures left for the user that is viewing them to play. If there arent any fixtures, I dont want that competition to be displayed Link to comment https://forums.phpfreaks.com/topic/170154-crossing-two-tables/#findComment-897559 Share on other sites More sharing options...
onthespot Posted August 13, 2009 Author Share Posted August 13, 2009 Anyone out there? Link to comment https://forums.phpfreaks.com/topic/170154-crossing-two-tables/#findComment-897571 Share on other sites More sharing options...
kingnutter Posted August 13, 2009 Share Posted August 13, 2009 I'm pretty sure this is to do with JOIN, but I'll leave it to the experts to tell you properly. This is actually a MYSQL command so someone wil probably move this post to the right spot soon. Speaking from experience you understand. Link to comment https://forums.phpfreaks.com/topic/170154-crossing-two-tables/#findComment-897577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.