PHP and MySQL: Number of rows returned

前端 未结 2 1260
眼角桃花
眼角桃花 2021-01-15 12:41

How can I see how many rows the following query returns?

mysql_select_db($database_aoldatabase, $aoldatabase);

$query1 = \"select * from sale where secid  =         


        
2条回答
  •  走了就别回头了
    2021-01-15 13:22

    Like Michiel said, mysql_num_rows() do the job. But if you want to work with more than one rows using an array, you can use count() too.

    $data = array();
    while($row = mysql_fetch_array($maxa, MYSQL_ASSOC)) {
      $data[] = $row;
    }
    $count1 = mysql_num_rows($maxa);
    $count2 = count($data);
    

提交回复
热议问题