scvinodkumar Posted February 2, 2009 Share Posted February 2, 2009 Hi there, i am using smarty currently for my projects. when i start loading the page, the browser shows me white blank page. only the loading complete its show me the whole page. is there any way to load the page little bit? Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/ Share on other sites More sharing options...
genericnumber1 Posted February 2, 2009 Share Posted February 2, 2009 Smarty collects all of the html in a buffer and dumps it in the end I think... so.... no. :X sorry Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752353 Share on other sites More sharing options...
arwvisions Posted February 2, 2009 Share Posted February 2, 2009 how long are you having to wait? Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752356 Share on other sites More sharing options...
scvinodkumar Posted February 2, 2009 Author Share Posted February 2, 2009 since i have three nested loop so its takes more than 1 minute to load the whole page. Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752359 Share on other sites More sharing options...
genericnumber1 Posted February 2, 2009 Share Posted February 2, 2009 You can always do echos followed by flush()es, but this completely voids the point of template systems like smarty. Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752363 Share on other sites More sharing options...
scvinodkumar Posted February 2, 2009 Author Share Posted February 2, 2009 so there is no any other to do? Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752364 Share on other sites More sharing options...
trq Posted February 2, 2009 Share Posted February 2, 2009 since i have three nested loop so its takes more than 1 minute to load the whole page. I assume these loops contain nested queries? Sounds like you need to rethink your logic so you don't have nested loops. Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752370 Share on other sites More sharing options...
Psycho Posted February 2, 2009 Share Posted February 2, 2009 since i have three nested loop so its takes more than 1 minute to load the whole page. I assume these loops contain nested queries? Sounds like you need to rethink your logic so you don't have nested loops. I second that. Based upon many samples of code I have seen posted in these forums I would be that you are using three sets of nested queries when you could get all of your data with just one. Post your code around these loops and we may be able to help reduce the processing time considerably. Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752372 Share on other sites More sharing options...
scvinodkumar Posted February 2, 2009 Author Share Posted February 2, 2009 i have pasted below the code that i used, i am writing the output to an xml file $query = "select * from fr_subcategories1 where catid=7 and parent_level=2 order by priority"; $result = mysql_query($query) or die(mysql_error()); while($fetch = mysql_fetch_object($result)) { $box_name = 'Box'.$main_count; $query1 = "select * from fr_subcategories1 where catid=".$fetch->subid." and parent_level=3 order by priority limit 6"; $result1 = mysql_query($query1) or die(mysql_error()); if(mysql_num_rows($result1)>0) { $count_start = 1; $category_name = $fetch->subcategory_title; while($fetch1 = mysql_fetch_object($result1)) { $query2 = "SELECT f.id 'fid',f.category_id,i.* FROM fr_feeds f JOIN fr_categories cat ON ( f.category_id = cat.id ) JOIN fr_items i ON ( i.feed_id = f.id ) where (lower(i.content) like '%".$fetch1->subcategory_title."%' or lower(i.title) like '%".$fetch1->subcategory_title."%') and category_id=7 AND (i.featured=1 or i.featured=0) AND DATE_FORMAT(publish_time, '%Y-%m-%d') = CURDATE() GROUP BY i.feed_id ORDER BY i.vote DESC, i.publish_time DESC , i.id DESC limit 3"; //echo $query2; //echo "<br>"; $result2 = mysql_query($query2) or die(mysql_error()); if(mysql_num_rows($result2)==0) { $query2 = "SELECT f.id 'fid',f.category_id,i.* FROM fr_feeds f JOIN fr_categories cat ON ( f.category_id = cat.id ) JOIN fr_items i ON ( i.feed_id = f.id ) where (lower(i.content) like '%".$fetch1->subcategory_title."%' or lower(i.title) like '%".$fetch1->subcategory_title."%') and category_id=7 AND (i.featured=1 or i.featured=0) AND DATE_FORMAT(publish_time,'%Y-%m-%d') = DATE_FORMAT(DATE_ADD(CURDATE(),INTERVAL -1 DAY ) , '%Y-%m-%d') GROUP BY i.feed_id ORDER BY i.vote DESC, i.publish_time DESC , i.id DESC limit 3"; $result2 = mysql_query($query2) or die(mysql_error()); } if(mysql_num_rows($result2)==0) { $query2 = "SELECT f.id 'fid',f.category_id,i.* FROM fr_feeds f JOIN fr_categories cat ON ( f.category_id = cat.id ) JOIN fr_items i ON ( i.feed_id = f.id ) where (lower(i.content) like '%".$fetch1->subcategory_title."%' or lower(i.title) like '%".$fetch1->subcategory_title."%') and category_id=7 AND (i.featured=1 or i.featured=0) GROUP BY i.feed_id ORDER BY i.vote DESC, i.publish_time DESC , i.id DESC limit 3"; $result2 = mysql_query($query2) or die(mysql_error()); } if(mysql_num_rows($result2)>0) { $_xml .="\t<".$box_name." id='".$count_start."'>\r\n"; $index_id = 1; $row_id =1; while($fetch2 = mysql_fetch_object($result2)) { if($count_start<=3) { $_xml .="\t\t<title".$row_id.">".htmlspecialchars($fetch2->title)."</title".$row_id.">\r\n"; $_xml .="\t\t<link".$row_id.">".htmlspecialchars("liststory.php?id=".$fetch2->id)."</link".$row_id.">\r\n"; } else { if($index_id<=2) { $_xml .="\t\t<title".$row_id.">".htmlspecialchars($fetch2->title)."</title".$row_id.">\r\n"; $_xml .="\t\t<link".$row_id.">".htmlspecialchars("liststory.php?id=".$fetch2->id)."</link".$row_id.">\r\n"; } $index_id++; } $row_id++; } $_xml .="\t</".$box_name.">\r\n"; $count_start++; } else { $_xml .="\t<".$box_name." id='".$count_start."'>\r\n"; $_xml .="\t\t<title1>No News Found</title1>\r\n"; $_xml .="\t\t<link1></link1>\r\n"; $_xml .="\t</".$box_name.">\r\n"; $count_start++; } /*$count_cat++; $count_start++; } } $main_count++; } Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752377 Share on other sites More sharing options...
scvinodkumar Posted February 2, 2009 Author Share Posted February 2, 2009 is there any solution to speedup the query? Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752403 Share on other sites More sharing options...
Psycho Posted February 2, 2009 Share Posted February 2, 2009 Yes, absolutely. I am by no means a SQL guru though. I would suggest prosting in the MySQL forum. But, looking at your first two queries, I *think* you could accomplish getting all of the same data without the two looping queries with just one query such as the one below. I have not tested it so I can't say if it will work. But, I know there is a solution, just not an expert in the syntax SELECT t1.subid as p_subid, t1.subcategory_title as p_subcategory_title FROM fr_subcategories1 t1 JOIN (SELECT * FROM fr_subcategories1 WHERE catid=t1.subid AND parent_level=3 ORDER BY priority LIMIT 6) AS t2 ON t1.subid = t2.catid WHERE t1.catid=7 AND t1.parent_level=2 ORDER BY t1.priority, t2.priority Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-752600 Share on other sites More sharing options...
scvinodkumar Posted February 13, 2009 Author Share Posted February 13, 2009 thanks for your help Link to comment https://forums.phpfreaks.com/topic/143433-how-to-load-the-page/#findComment-761202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.