-
another SQL question
ive got
PHP Code:
$sql="SELECT gamename FROM reviews WHERE id='$id'";
$result = mysql_query($sql);
while ($row = mysql_fetch_row($result)) {
$gamename=$row['gamename'];
}
$sql="SELECT * FROM reviews WHERE gamename='$gamename'";
$result = mysql_query($sql);
while ($row = mysql_fetch_row($result)) {
//outputs the results into a table
//new table for every review
}
any problems with that? i want to get one id, but pull up reviews for multiple entries for that game.
also, i'm a bit confused. suppose i have multiple reviews for the game x. wouldnt it pull up the first review it finds?
-
it might be better to assign each game a unique ID rather than relying on the game name.
Provided you use the while statement like you are, you'll get all rows that match, it's then up to you within the while statement to output each row to the browser.
It does require a little modification though in it's current form, try this
PHP Code:
$sql="SELECT gamename FROM reviews WHERE id='$id'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$gamename=$row['gamename'];
$reviewsql="SELECT * FROM reviews WHERE gamename='$gamename'";
$reviewresult = mysql_query($reviewsql);
while ($reviewrow = mysql_fetch_array($reviewresult)) {
//outputs the results into a table
//new table for every review
}
}
-
hmm maybe i could do that. but the people can add games on...so id have another table which sotres the name and the id.
then have a column in the reviews for "gameid"?
which method would be more effecient? i have almost everything setup, except for editing and this one part done, with it relying on gamename
-
thinking about it now, that might be easier
-
okay, i got it working, thanks for your help :)