SQL return error within PHP
Posted
by Luke
on Stack Overflow
See other posts from Stack Overflow
or by Luke
Published on 2010-05-20T21:15:23Z
Indexed on
2010/05/20
21:20 UTC
Read the original article
Hit count: 213
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?
© Stack Overflow or respective owner