Greetings, the following code:

$usertr = mysql_query("SELECT * FROM allurlszhhk"); $rowtr = mysql_fetch_array($usertr); $count = count($rowtr); echo $count ; 

displays 6 when the fields in the database are 275

  • Schip? ........... - user207618
  • )) Not sleeping! Any ideas?) - Victor Vasilyev
  • You have 275 columns or rows? - Mihanik71
  • Strok shot.qip.ru/00tXa3-13YtCRM9J - Victor Vasilyev
  • one
    mysql_fetch_array returns the next entry, and not all at once, is it not? And there are six fields coming out. - user207618

1 answer 1

mysql_fetch_array returns one row of data. To count the number of records in a table, you can use

 $res = mysql_query("SELECT COUNT(*) FROM table_name"); $row = mysql_fetch_row($res); $total = $row[0]; echo $total; 
  • one
    May be ... mysql_num_rows ? - user207618
  • That's right, thanks! - Victor Vasilyev
  • one
    @Other so we only get the quantity, and if through mysql_num_rows then we will select all the data and then calculate them. And if the table is not 275 lines, but several millions? - Mihanik71
  • Just suggested. I did not work with mysql_* , only with PDO . - user207618
  • @Other and in PDO rowCount first executes the query, and then it counts the rows - Mihanik71