Results 1 to 5 of 5

Thread: another SQL question

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    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?
    Last edited by nabeels786; Apr 18th, 2002 at 07:18 PM.
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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
        
    }

    Last edited by chrisjk; Apr 18th, 2002 at 07:26 PM.

  3. #3

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    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
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  4. #4

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    thinking about it now, that might be easier
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  5. #5

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    okay, i got it working, thanks for your help
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width