How to return the number of rows in php to test

Discussion in 'Databases' started by gibsongk55, Sep 9, 2010.

  1. #1
    Here is the code... how do i return the number of rows in query?

        $arr_Out = array();
        $result = $db->query("SELECT id,title,approve FROM dle_post");
        while ($row2 = $db->get_row($result)) {
            $title_id[$row2['id']] = stripslashes($row2['title']);
        }
        
    $result = $db->query("SELECT * FROM dle_images RIGHT JOIN dle_post ON dle_images.news_id = dle_post.id where dle_post.approve = 1 ORDER BY RAND()  LIMIT 20");
    
    Code (markup):
     
    gibsongk55, Sep 9, 2010 IP
  2. skum

    skum Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $result->num_rows();
     
    skum, Sep 10, 2010 IP
  3. gibsongk55

    gibsongk55 Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    Thanks for the reply. Can you put that into code that works?

    I get "Fatal error: Call to undefined function num_rows() "

    Thanks,

    Gibs
     
    gibsongk55, Sep 10, 2010 IP
  4. Mohie

    Mohie Peon

    Messages:
    122
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hello,
    try
    $x=mysql_num_rows($result);
    echo $x;




    regards =)
    Mohie
     
    Mohie, Sep 10, 2010 IP