Jump to content

query making my page slow ... help?


Gem

Recommended Posts

Hiya ..

 

Hopefully just a quick question ..

 

my new homepage ... www.bradleystokejudoclub.co.uk/newindex.php

is loading incredibly slow, and I figure it is because of the query that is in the Latest News section ...

 

Is there a way to load the rest of the page and not have to wait for the query ... maybe some kind of "loading" in the latest news bit whilst its getting there??

 

Hope that makes sense...

 

thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/149186-query-making-my-page-slow-help/
Share on other sites

Sure ...

 

<?php
$con = mysql_connect(" =) ");
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("bssql", $con);
$result = mysql_query("SELECT `title`, `subtitle` FROM `articles` ORDER BY `ID` DESC LIMIT 5") or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
    ?><b><?php echo $row['title'];?></b> 
    <BR><?php echo $row['subtitle']?><BR><?php
}
mysql_close($con);
?>

gemmerz, if you want the page to display and don't mind the delay for the last part, may i suggest using flush()

 

ie

<?php
echo "Start of the page..<br>";
flush();
sleep(2); //delays
echo "Rest of the page";
?>

 

as for your mysql connection, i assume your using localhost!

 

you say you figure it because of the sql.. but is this a guess or have you tried removing it to see if it speeds up ?

Archived

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

×
×
  • 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.