Jump to content


Photo

Echoing to Browser Problem


  • Please log in to reply
5 replies to this topic

#1 atbjk

atbjk
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 19 April 2006 - 04:14 PM

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>';
}

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 19 April 2006 - 04:17 PM

[!--quoteo(post=366478:date=Apr 19 2006, 05:14 PM:name=atbjk)--][div class=\'quotetop\']QUOTE(atbjk @ Apr 19 2006, 05:14 PM) View Post[/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.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 atbjk

atbjk
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 19 April 2006 - 04:30 PM

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

#4 atbjk

atbjk
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 19 April 2006 - 05:59 PM

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

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 19 April 2006 - 06:06 PM

What redbullmarky meant was instead of looping through your results in a for loop just use a while loop.
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>';
}


#6 Dobakat

Dobakat
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 19 April 2006 - 06:07 PM

I belive you are missing a ' in:
$results=mysqltalk ('SELECT * FROM `cf_category` ORDER BY cateorgnum ASC );
It should be aa:
$results=mysqltalk ('SELECT * FROM `cf_category` ORDER BY cateorgnum ASC' );

well just a mistake I saw...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users