How can I obtain a row of data and the number of rows of all data?

Source: Internet
Author: User
I added $ myrowmysql_fetch_row ($ res); why can't I get a row of data (!) Warning: mysql_fetch_row () expectsparameter1toberesource, arraygiveninD: wampwwwchaxun. phpo... I added $ myrow = mysql_fetch_row ($ res); why can't I get a row of data (! ) Warning: mysql_fetch_row () expects parameter 1 to be resource, array given in D: \ wamp \ www \ chaxun. php on line 7


  prepare("select * from test"); $stmt->execute(); //$myrow = mysql_fetch_row($stmt->execute()); $res=$stmt->fetch(); $myrow = mysql_fetch_row($res); print_r($myrow);?>

Reply content:

I added $ myrow = mysql_fetch_row ($ res); why can't I get a row of data (! ) Warning: mysql_fetch_row () expects parameter 1 to be resource, array given in D: \ wamp \ www \ chaxun. php on line 7


  prepare("select * from test"); $stmt->execute(); //$myrow = mysql_fetch_row($stmt->execute()); $res=$stmt->fetch(); $myrow = mysql_fetch_row($res); print_r($myrow);?>

PDOStatement: rowCount-returns the number of rows affected by the previous SQL statement.

PDOStatement: fetch-get the next row from the result set


  Query ('select * from users'); // get a row $ result = $ query-> fetch (); print_r ($ result ); $ total = $ pdo-> query ('select * from test'); // count $ count = $ total-> rowCount (); echo $ count;

Use a while loop.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.