sql >> Database teknologi >  >> RDS >> Mysql

MySQL - tæl det samlede antal rækker i php

<?php
$con = mysql_connect("server.com","user","pswd");
if (!$con) {
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("db", $con);

$result = mysql_query("select count(1) FROM table");
$row = mysql_fetch_array($result);

$total = $row[0];
echo "Total rows: " . $total;

mysql_close($con);
?>


  1. mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows osv... forventer, at parameter 1 er ressource

  2. TIME_FORMAT() Eksempler – MySQL

  3. Vigtig PostgreSQL-overvågning - del 1

  4. SQL Server 2016:Opret en visning