PHP - $num_of_rows - How to summarize from an array
Posted: Mon Dec 15, 2008 4:05 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I have a page that searches mssql and returns a result set. I use $num_of_rows = mssql_num_rows ($msresults); to get the number of results. So far so good. After this comes my for statement and each line item of my results. I use an if statement to determine whether the line item is allowed to be viewed by the end user. So, my result set may have 15, but only 5 of those are being displayed to the end user. What I want to know is how do I make $num_of_rows reflect only what I am showing to the viewers instead of the total of all records found from the sql search... I can create a variable with a 1 if the viewer is allowed to see the data, and a 0 if they are not, but I do not know how to get that sum into the $num_of_rows variable... hopefully this is clear enough that someone could enlighten me...
Laura
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I have a page that searches mssql and returns a result set. I use $num_of_rows = mssql_num_rows ($msresults); to get the number of results. So far so good. After this comes my for statement and each line item of my results. I use an if statement to determine whether the line item is allowed to be viewed by the end user. So, my result set may have 15, but only 5 of those are being displayed to the end user. What I want to know is how do I make $num_of_rows reflect only what I am showing to the viewers instead of the total of all records found from the sql search... I can create a variable with a 1 if the viewer is allowed to see the data, and a 0 if they are not, but I do not know how to get that sum into the $num_of_rows variable... hopefully this is clear enough that someone could enlighten me...
Code: Select all
<?php
SQL SEARCH DONE HERE
$num_of_rows = mssql_num_rows ($msresults);
for($i=0; $i<$RowPerPage; $i++) {
$row = mssql_fetch_array($msresults);
if(!$row){ break; }
VARIABLES SET HERE
If (Statement to determine which data is viewable) {
echo DATA;
}~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: