This tutorial, I will show you how to display total number of rows in table and rows found due to the MySQL query you executed.I have used the same table progress use in a previous tutorial.
create the php file and find the result as bellow.
<?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_database", $con); $q=mysql_query("SELECT *FROM progress"); $result = mysql_query("SELECT *FROM progress WHERE Month IN ( 'January', 'February', 'March' )"); $rows = mysql_num_rows($q); echo "<table border='1'> <tr> <th>Month</th> <th>Nuber of Products</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Month'] . "</td>"; echo "<td>" . $row['Production'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "There are ".mysql_num_rows($result)." Result(s) found."; echo "Total of " . $rows . " rows in table."; mysql_close($con); ?> |
|
No comments:
Post a Comment