explain me this query

Discussion in 'PHP' started by x0x, Sep 12, 2008.

  1. #1
    $stuff= mysql_query("SELECT id FROM talbe WHERE id>0 ORDER BY money DESC;");
    while ($omg= mysql_fetch_array($stuff))


    I see a lot of those in my code, can't it just be pulled with one command or what? mysql_fetch_array(mysql_query
     
    x0x, Sep 12, 2008 IP
  2. seoalan

    seoalan Peon

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    no my friend it wont work..first you need to fire query then only result can be fetched from array...
     
    seoalan, Sep 12, 2008 IP
  3. Jaundice

    Jaundice Peon

    Messages:
    73
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Here is an example, notice that I've used the newer "mysqli" variant and that is has slightly different parameter requirements (notably a "link" for query actions).

    $sql = "...";
    if ( !$res=mysqli_query($link,$sql) )
       die("ERROR: Unable to query!\n");
    
    while ( $row=mysqli_fetch_assoc($res) )
    {
       ...
    }
    mysqli_free_result($res);
    Code (markup):
     
    Jaundice, Sep 12, 2008 IP