Jump to content


Photo

mysql query load half way


  • Please log in to reply
4 replies to this topic

#1 eternkid

eternkid
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 27 September 2006 - 07:16 PM

Hi, I have a weird problem with mysql query. I'm running apache on a windows server with mysql and php.
I got my sql query, when i try to print out the data, it only loads part of the data. When i click on refresh, sometimes it loads fully, sometimes it loads a third, sometimes it loads a fourth of the way. Basically i have a sql statement that gets 8 fields per row from a table. When the data gets about 30+ rows, it stops loading. and when i click refresh a few times, sometimes it loads another 10 or so more rows. When i try it on my old laptop, it's even worst. It gets like 10 rows. Sometimes it goes to a blank page. Please help. thanks

example code assuming all syntax is correct:

$sql = select * from mytable where id=$id;
$result = mysql_query($sql) or die(mysql_error());
while($myrow=mysql_fetch_array(results))
{
$field1 =$myrow["data1"]
$field2...................
.
$field8....................
printf(<td>%s</td>", $field1);
printf(<td>%s</td>", $field2);
.....................
}

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 27 September 2006 - 07:17 PM

Not sure... could be a browser-rendering issue.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 eternkid

eternkid
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 27 September 2006 - 07:29 PM

The thing is, it runs better on firefox than IE. But when i run someone elses script with a bigger database, it works perfectly. I try to printf 200 plus rows with 8 fields per row with that script, it came out perfectly. I really don't see much difference with the code, basically this person's used a class to store the fields.
eg: i use $field1=$myrow[field1];
he used a class, inside this class are variables $field1 $field2......

printout
i, printf(<td> $field1 </td>)

he,
t=new class(<mysql_result()>);
<td> t->get("field1");</td>

this is driving me nuts.
any help woudl be much appreciated.


#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 27 September 2006 - 09:17 PM

Again, this is not MySQL-related... this has to do with how the browsers handle the output stream, and tables are notorious for rendering.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 eternkid

eternkid
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 27 September 2006 - 09:23 PM

solved it...
apparently the queries were too fast and the printout couldn't catch up. so what i did was slow it down by using usleep(100000);, this makes the query to pause for 1/10 of a sec. Dont' know why it's like this but it works. so i'm happy, thanks for your fast replies.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users