Current location: Hot Scripts Forums » Programming Languages » PHP » Total mysql_num_rows on while loop


Total mysql_num_rows on while loop

Reply
  #1 (permalink)  
Old 08-21-05, 09:39 AM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
Question Total mysql_num_rows on while loop

I'm using the following loop to get results of how many times a url is located on the database.

Query:
1. I want to know how I can total the ammount (all rows added together) at the end of the loop?

and

2. Is it possiable to put these results in numerical order using php?

PHP Code:

        // Loop Start

        
while ($out_list=mysql_fetch_array($out_result)) 
        {
        
        
$varwhole $out_list['out'];
        
$total_link mysql_query("SELECT `out` FROM `webstat` WHERE 1 AND `out` LIKE '$varwhole'");

        
//echo the whole this
        
echo '
        <tr>
        <td WIDTH="75" CLASS="text">'
mysql_num_rows($total_link) .'</td>
        </tr>'
;
        
        } 
I think the best way is probably to loop the information first to sort it and loop it again to get the final results? But I have no idea how to go about this! Help

Last edited by dihan; 08-21-05 at 09:53 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-21-05, 10:23 AM
DetroitGuy DetroitGuy is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

//Count Results

        
$total_overall mysql_query("SELECT count(out) FROM webstat WHERE 1 AND `out` LIKE '$varwhole'")
        or die (
"Could not connect to mysql because ".mysql_error());

// Loop Start
        
while ($out_list=mysql_fetch_array($out_result))
        {
        
$varwhole $out_list['out'];
        
$total_link mysql_query("SELECT 'out' FROM `webstat` WHERE 1 AND `out` LIKE '$varwhole'" order by out desc);
        
//echo the whole this
        
echo '
        <tr>
        <td WIDTH="75" CLASS="text">'
mysql_num_rows($total_link) .'</td>
        </tr>'
;
        } 
print 
"$total_overall links."

Last edited by DetroitGuy; 08-21-05 at 10:25 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-21-05, 04:31 PM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks DetroitGuy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SUM and how to get the total value? Programme PHP 3 06-30-05 04:17 PM
Having a problem with a large while loop. . . Spreegem PHP 13 05-03-05 06:53 AM
how do i get the total number of listed items in a for loop? nassau PHP 3 02-07-05 11:09 PM
While loop jaishalg PHP 1 11-23-04 04:36 PM
is it a good idea to run 23 search expressions? lordmerlin ASP 1 03-24-04 05:05 PM


All times are GMT -5. The time now is 07:21 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.