wkilc Posted July 16, 2008 Share Posted July 16, 2008 I am attempting to customize a paging script I found on a tutorial. The script works wonderfully, except that it counts the TOTAL number of records in the table. I would like to be able to count the "current" number of records, which can be determined by the URL. For example... if the page was "index.php", there might be 1200 records in the table all total. At 100 records per page, there are going to be "paging" links for 12 pages. But if I filtered the results (index.php?instrument=flute") for example, I want the paging to handle just the, let's say, 200 flute records in the table, not all 1200. With only 200 results for flutes (or whatever), it should show links for only 2 pages. /////////////// WE have to find out the number of records in our table. We will use this to break the pages/////// $query2=" SELECT * FROM mytablename "; $result2=mysql_query($query2); echo mysql_error(); $nume=mysql_num_rows($result2); /////// The variable nume above will store the total number of records in the table//// ?> Thank you. ~Wayne Quote Link to comment https://forums.phpfreaks.com/topic/115131-solved-counting-current-number-of-rows/ Share on other sites More sharing options...
sader Posted July 16, 2008 Share Posted July 16, 2008 $query2=" SELECT * FROM mytablename WHERE instrument='flute'"; then mysql_num_raws($query) should return 200 Quote Link to comment https://forums.phpfreaks.com/topic/115131-solved-counting-current-number-of-rows/#findComment-592081 Share on other sites More sharing options...
wkilc Posted July 17, 2008 Author Share Posted July 17, 2008 Thank you. The problem is that there are several dozen types of instruments that can be "filtered" from the table. I also may need to filter it by a different column (other than instrument) as well. Is there a way to do it without hard coding it? ~Wayne Quote Link to comment https://forums.phpfreaks.com/topic/115131-solved-counting-current-number-of-rows/#findComment-592102 Share on other sites More sharing options...
wkilc Posted July 17, 2008 Author Share Posted July 17, 2008 Got it! I think. $query2="SELECT * FROM mytablename WHERE (mytablename.instrument LIKE '$instrument%')"; Thank you!!! ~Wayne Quote Link to comment https://forums.phpfreaks.com/topic/115131-solved-counting-current-number-of-rows/#findComment-592108 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.