Retrieving multiple rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sake
    New Member
    • Jan 2007
    • 46

    Retrieving multiple rows

    Hey Everyone,
    Here's the code:
    [php]
    $query = mysql_query("SE LECT 'column' FROM table WHERE location='$loca tion'");
    $queryA = mysql_fetch_arr ay($query,MYSQL _NUM);
    [/php]
    MYSQL_NUM_ROWS claims that $query returns 2 rows. However, for some I am not able to access $queryA. I imagine some thing's wrong with my fetch array function. But I'm kind of at a loss of ideas here.

    Thanks alot for the help,
    Sake
  • rpnew
    New Member
    • Aug 2007
    • 189

    #2
    Originally posted by sake
    Hey Everyone,
    Here's the code:
    [php]
    $query = mysql_query("SE LECT 'column' FROM table WHERE location='$loca tion'");
    $queryA = mysql_fetch_arr ay($query,MYSQL _NUM);
    [/php]
    MYSQL_NUM_ROWS claims that $query returns 2 rows. However, for some I am not able to access $queryA. I imagine some thing's wrong with my fetch array function. But I'm kind of at a loss of ideas here.

    Thanks alot for the help,
    Sake
    Hi,
    Can you a provide a bit of more code.. where are you using this $queryA and how are you using it?

    Regards,
    RP

    Comment

    • sake
      New Member
      • Jan 2007
      • 46

      #3
      [php]
      $query = mysql_query("SE LECT 'Id' FROM mobs WHERE location='$loca tion'");
      $aMobs = mysql_fetch_arr ay($query,MYSQL _NUM);//available mobs
      $randMob = rand()%(mysql_n um_rows($query)-1);
      $lastMob = $aMobs[randMob];
      [/php]
      So pretty much i'm trying to get all Id's where their location = $location. Then i want to randomly select an Id from the aMobs array. Any ideas?

      Comment

      • sandeepsandeep
        New Member
        • Dec 2006
        • 50

        #4
        Originally posted by sake
        Hey Everyone,
        Here's the code:
        [php]
        $query = mysql_query("SE LECT 'column' FROM table WHERE location='$loca tion'");
        $queryA = mysql_fetch_arr ay($query,MYSQL _NUM);
        [/php]
        MYSQL_NUM_ROWS claims that $query returns 2 rows. However, for some I am not able to access $queryA. I imagine some thing's wrong with my fetch array function. But I'm kind of at a loss of ideas here.

        Thanks alot for the help,
        Sake

        Use this and retrive the all row

        $query = mysql_query("SE LECT 'column' FROM table WHERE location='$loca tion'");

        while ($row = mysql_fetch_arr ay($query, MYSQL_NUM)) {
        printf("Column: %s ", $row[0]);
        }

        Comment

        Working...