Jump to content

Echoing to Browser Problem


atbjk

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>';
}
Link to comment
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.
Link to comment
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
Link to comment
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]
Link to comment
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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.