PHP and mssql problem (only print one record)

Discussion in 'PHP' started by plumni, Jan 24, 2010.

  1. #1
    When I use the code below:

    $result=mssql_query("select * from table");
    $rows=mssql_fetch_row($result);
    print_r($rows);

    The print is only one record of the table "table".
    like this:
    Array
    (
    [0] => 1
    [1] => 2
    [2] => 3
    )

    But,actually,there are more than one record in this table.
    And also it is no problem in the connection of the database.

    What's possible reasons are there?
     
    plumni, Jan 24, 2010 IP
  2. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    you need a loop
    
    $result=mssql_query("select * from table");
    while ($rows=mssql_fetch_row($result)){
    print_r($rows);
    }
    Code (markup):
     
    javaongsan, Jan 24, 2010 IP
  3. plumni

    plumni Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    oh,thanks.
     
    plumni, Jan 25, 2010 IP