PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 16th, 2005, 02:09 AM
OXIallaFORUM OXIallaFORUM is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 1 OXIallaFORUM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 29 m 46 sec
Reputation Power: 0
20.000 rows to display. BEST WAY ?

OK there are more than 20.000 simple words in MySQL DB table.
To get the results by the queries is fast,
but it takes a long time to display them to a client browser.
Is there a way that this long-time action could be transparent to the client ?

thanx

Reply With Quote
  #2  
Old September 16th, 2005, 04:01 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 1,029 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 1 Week 12 h 41 m 23 sec
Reputation Power: 15
Send a message via ICQ to Itsacon
You could use output buffering and flush the buffers every 10 records or so.
That way the client would start seeing output before the script is done:
PHP Code:
<html>
<
body>
<?
php
ob_start
();

$db = new mysqli(/*connection info*/);

$result $db->query("SELECT * FROM Table");

$temp $result->fetch_fields();
echo 
"<table>\n<tr>";
foreach(
$temp as $record)
    echo 
"<th>".$record->name."</th>";
echo 
"</tr>\n";

$counter 0;
while(
$temp $result->fetch_row())
{
    echo 
"<tr>";
    foreach(
$temp as $record)
        echo 
"<td>".$record."</td>";
    echo 
"</tr>\n";
    if(
$counter 10)
    {
        
ob_flush();
        
$counter 0;
    }
    else
        
$counter++;
}    
echo 
"</table>\n";

ob_end_flush();

?>
</body>
</html> 
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 592

Reply With Quote
  #3  
Old September 16th, 2005, 09:08 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Is it necessary to display them all on the same page?
Another option could be pagination.

Reply With Quote
  #4  
Old September 16th, 2005, 10:42 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
20,000 words

I like to see at least something while a lengthy process is going on, even a fake progress bar so I know the page hasn't froze, or something to start reading or look at. Itsacon's post is appropriate if the display lag is a result of database processing. My intuition says it is.
Quote:
Originally Posted by OXIallaFORUM
To get the results by the queries is fast, but it takes a long time to display them to a client browser.
If you had an HTML version of the output that did not use the database, but that had the results already in it, would it still take a long time to display?
Either way, database processing or text transfer, MadCowDzz's suggestion of using pagination sounds like a good idea to me too.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > 20.000 rows to display. BEST WAY ?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap