my sql best practice with php for counting rows

前端 未结 4 894
情书的邮戳
情书的邮戳 2021-01-28 18:31

1) Count record:

//Connect to mysql server
$link = mysql_connect(HOST, USER, PASSWORD);
if(!$link) {
    die(\'Could not connect to server: \' . mysql_error());
         


        
4条回答
  •  长情又很酷
    2021-01-28 19:25

    mysql has a count function:

    http://dev.mysql.com/doc/refman/5.1/en/counting-rows.html

    so you could use:

    SELECT COUNT(*) FROM table WHERE abc=123
    

    or whatever condition.

提交回复
热议问题