Jump to content

Archived

This topic is now archived and is closed to further replies.

atbjk

Echoing to Browser Problem

Recommended Posts

i am haveing a problem echoing to the broswer. i am reading from a mysql database and then echoing the results to the browser in a neat table. everything works well when there are 100 records when when i try to echo a 1000 records to the broswer it chokes. I am using firefox and ie to test my script. here is the code i use


$results=mysqltalk ('SELECT * FROM `cf_category` ORDER BY cateorgnum ASC );
$num_rows=mysql_num_rows($results);
for($i=0; $i<$num_rows; $i++) {
$row=mysql_fetch_assoc($results);
echo '<table><tr><td width="137" valign="top">SAMPLE ROW DAta</td>
<td width="425">SAMPLE ROW DAta</td></tr></table>';
}

Share this post


Link to post
Share on other sites
[!--quoteo(post=366478:date=Apr 19 2006, 05:14 PM:name=atbjk)--][div class=\'quotetop\']QUOTE(atbjk @ Apr 19 2006, 05:14 PM) [snapback]366478[/snapback][/div][div class=\'quotemain\'][!--quotec--]
i am haveing a problem echoing to the broswer. i am reading from a mysql database and then echoing the results to the browser in a neat table. everything works well when there are 100 records when when i try to echo a 1000 records to the broswer it chokes. I am using firefox and ie to test my script. here is the code i use
$results=mysqltalk ('SELECT * FROM `cf_category` ORDER BY cateorgnum ASC );
$num_rows=mysql_num_rows($results);
for($i=0; $i<$num_rows; $i++) {
$row=mysql_fetch_assoc($results);
echo '<table><tr><td width="137" valign="top">SAMPLE ROW DAta</td>
<td width="425">SAMPLE ROW DAta</td></tr></table>';
}
[/quote]

when you say 'chokes', what exactly do you mean? you get an error? firefox crashes? nothing happens?

have you tried it in other browsers?

altho its not the way i'd personally put your code together, there's nothing actually wrong with it as far as i can see in terms of it working.

Share this post


Link to post
Share on other sites
yes it does not open correctly, first it opens, looks like it working then it looks like it is redirecting/reloading then it says pages can not be displayed i tested it in both browsers.

also how would you code it please explain?

also i can let you see a live example if you want

Share this post


Link to post
Share on other sites
i found out what the problem was, its had to deal with the max excution time for the script. arround 100 rows to echo to broswer is best number

Share this post


Link to post
Share on other sites
What redbullmarky meant was instead of looping through your results in a for loop just use a while loop.
[code]while($row = mysql_fetch_assoc($results))
{
    echo '<table><tr><td width="137" valign="top">SAMPLE ROW DAta</td>
<td width="425">SAMPLE ROW DAta</td></tr></table>';
}[/code]

Share this post


Link to post
Share on other sites
I belive you are missing a ' in:
[code]
$results=mysqltalk ('SELECT * FROM `cf_category` ORDER BY cateorgnum ASC );
[/code]
It should be aa:
[code]
$results=mysqltalk ('SELECT * FROM `cf_category` ORDER BY cateorgnum ASC' );
[/code]

well just a mistake I saw...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.