arijulianto

Count Data from a Table

Dec 16th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.38 KB | None | 0 0
  1. // way 1
  2. $cat = $_GET['cat'];
  3. $sql = mysql_query("SELECT * from tablename where idcattegory='$cat'");
  4. $count = mysql_num_rows($sql);
  5.  
  6. echo "There are $count rows in table..";
  7.  
  8. // way 2
  9. $cat = $_GET['cat'];
  10. $sql = mysql_query("SELECT count(*) as total from tablename where idcattegory='$cat'");
  11. $data= mysql_fetch_array($sql);
  12.  
  13. echo "There are $data[total] rows in table..";
Advertisement
Add Comment
Please, Sign In to add comment