SQL return error within PHP
- by Luke
I use GET to get the id of a result.
$id = $_GET['id'];
I then use the following code:
<?
$q = $database->friendlyDetails($id);
while( $row=mysql_fetch_assoc($q) )
{
$hu = $row['home_user'];
$ht = $row['home_team'];
$hs = $row['home_score'];
$au = $row['away_user'];
$at = $row['away_team'];
$as = $row['away_score'];
$game = $row['game'];
$name = $row['name'];
$match = $row['match_report1'];
$compid = $row['compid'];
$date = $row['date_submitted'];
$sub = $row['user_submitted'];
}
?>
And friendDetails-
function friendlyDetails($i)
{
$q = "SELECT *
FROM ".TBL_SUB_RESULTS."
INNER JOIN ".TBL_FRIENDLY."
ON ".TBL_FRIENDLY.".id = ".TBL_SUB_RESULTS.".compid
WHERE ".TBL_SUB_RESULTS.".id = '$i'";
return mysql_query($q, $this->connection);
}
For some reason, the code will only return what is under id =1.
Can anyone see anything obvious I am doing wrong?