onthespot Posted July 22, 2009 Share Posted July 22, 2009 hey guys, this just keeps returning too many rows. can anyone help? <?php $fixtures = mysql_query("SELECT * FROM fixtures WHERE comp = '$_GET[comp]' AND (home_user like '$_SESSION[username]' or away_user like '$_SESSION[username]')"); while( $row = mysql_fetch_assoc($fixtures)) { extract($row); $info = explode("_",$row[comp]); ?> <h1 class="pagetitle"><? echo $info[2]?></h1><? } ?> The problem is that this keeps returning the row "comp" as many times as the amount of rows in total in that table. How can I stopthis? Link to comment https://forums.phpfreaks.com/topic/167055-solved-php-help-on-explode/ Share on other sites More sharing options...
dzelenika Posted July 23, 2009 Share Posted July 23, 2009 It must return all rows because is in loop. How many rows do you want? Link to comment https://forums.phpfreaks.com/topic/167055-solved-php-help-on-explode/#findComment-880856 Share on other sites More sharing options...
onthespot Posted July 23, 2009 Author Share Posted July 23, 2009 The part in question is the title for the page, however all the others are fixtures, so every row needs to be there. Basically I dont want the title attached to every fixture. If that makes sense? Link to comment https://forums.phpfreaks.com/topic/167055-solved-php-help-on-explode/#findComment-880857 Share on other sites More sharing options...
onthespot Posted July 23, 2009 Author Share Posted July 23, 2009 $fixtures = mysql_query("SELECT * FROM fixtures WHERE comp = '$_GET[comp]' AND (home_user like '$_SESSION[username]' or away_user like '$_SESSION[username]')"); while( $row = mysql_fetch_assoc($fixtures)) { $title=$row['comp']; echo"<h1 class=\"pagetitle\">$title</h1><table cellspacing=\"10\"> <tr> <td>Competition</td> <td>Game</td> <td>Format</td> </tr>"; } I tried this but still just returns the title as many times as the number of rows at the top. Just over and over. 4 fixtures, 4 titles, just this time each title is one after another at the top of the page. Link to comment https://forums.phpfreaks.com/topic/167055-solved-php-help-on-explode/#findComment-880858 Share on other sites More sharing options...
onthespot Posted July 23, 2009 Author Share Posted July 23, 2009 Found a way around this Link to comment https://forums.phpfreaks.com/topic/167055-solved-php-help-on-explode/#findComment-880862 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.