Jump to content

[SOLVED] Can anyone spot a mistake here? I can't!


onthespot

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.