onthespot Posted August 18, 2009 Share Posted August 18, 2009 Hey guys, the SQL query works as I echoed the num rows and there are rows, I just don't think I am displaying very well? <?php $results = mysql_query("SELECT * FROM submittedresults where home_user = '$_SESSION[username]' or away_user = '$_SESSION[username]'"); $num_rows = mysql_num_rows($results); if ($num_rows > 0) { while( $row = mysql_fetch_assoc($results)) { extract($row); $info = explode("_",$row[comp]); if ( $user_submitted != $_SESSION[username]) { ?> <div align="center"> <table cellspacing="10" style='border: 1px dotted' width="300" bgcolor="#eeeeee"> <tr> <td><b><? echo $info[2]; ?></b></td> </tr><tr> <td width="100"><? echo $home_user; ?></td> <td width="50"><? echo $home_score; ?></td> <td>-</td> <td width="50"><? echo $away_score; ?></td> <td width="100"><? echo $away_user; ?></td> </tr><tr> <td><A HREF="confirmresult.php?fixid=<? echo $fix_id; ?>">Accept / Decline</a></td> </tr></table></div><br> <? } } } else { echo "You currently have no results awaiting confirmation"; } ?> Thankyou Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/ Share on other sites More sharing options...
Maq Posted August 18, 2009 Share Posted August 18, 2009 So what's the problem? What do you want the end result to look like? Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901108 Share on other sites More sharing options...
deansatch Posted August 18, 2009 Share Posted August 18, 2009 $results = mysql_query("SELECT * FROM submittedresults where home_user = '".$_SESSION[username]."' or away_user = '".$_SESSION[username]."'"); *EDIT: removed a space. oops! Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901113 Share on other sites More sharing options...
onthespot Posted August 18, 2009 Author Share Posted August 18, 2009 Nothing is displayed at all! Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901116 Share on other sites More sharing options...
daveoffy Posted August 18, 2009 Share Posted August 18, 2009 Are you sure your sessions are set? Did you include the config to connect to database correctly? Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901119 Share on other sites More sharing options...
Maq Posted August 18, 2009 Share Posted August 18, 2009 Associative arrays should have single quotes around the keys. Have you echoed inside your IF statements to ensure they are being reached? Where is '$user_submitted' ever assigned a value? Don't use shortags (), always use <?php. Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901127 Share on other sites More sharing options...
mikesta707 Posted August 18, 2009 Share Posted August 18, 2009 its probably your associative array keys, as Maq has said. You probably have a mysql query error. Try doing or die("ERROR: " . mysql_error()); after your query, and surround your associative array keys with single quotes Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901140 Share on other sites More sharing options...
Maq Posted August 18, 2009 Share Posted August 18, 2009 its probably your associative array keys, as Maq has said. You probably have a mysql query error. Try doing or die("ERROR: " . mysql_error()); after your query, and surround your associative array keys with single quotes That's what I was thinking because usually it throws an error saying that the keys aren't defined constants. But the OP claimed that he echoed the num rows and it displayed... Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901145 Share on other sites More sharing options...
onthespot Posted August 18, 2009 Author Share Posted August 18, 2009 Yeah i echoed num rows and it displays them. I will add the error in. Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901146 Share on other sites More sharing options...
onthespot Posted August 18, 2009 Author Share Posted August 18, 2009 The user submitted variable is defined by the extract(row). Is there a way i can add into the sql WHERE user_submitte is not session[username]. That would remove that part from it? Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901151 Share on other sites More sharing options...
deansatch Posted August 18, 2009 Share Posted August 18, 2009 The user submitted variable is defined by the extract(row). Is there a way i can add into the sql WHERE user_submitte is not session[username]. That would remove that part from it? Do you mean as in this? WHERE user_submitte != '$_SESSION[username]' Link to comment https://forums.phpfreaks.com/topic/170858-solved-can-anyone-spot-a-mistake-here-i-cant/#findComment-901159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.