catalankh Posted January 18, 2013 Share Posted January 18, 2013 it working perfectly in local but in my website it display 3 time per article why? here my print_r PDOStatement Object ( [queryString] => SELECT `article`.`art_id` , `article`.`art_titleen` , `article`.`art_titlekh` , `article`.`art_postdate` , `article`.`art_detail` , `sub_menu`.`sub_name` FROM `article` , `sub_menu` WHERE `article`.`sub_name` = `sub_menu`.`sub_name` AND `article`.`sub_name` = 'phone' ORDER BY `article`.`art_postdate` DESC ) $dispart = fnc_select_article($targfields,$table,$field,$param,$targetfitler,"'".$andfilter."'"." ORDER BY art_postdate DESC LIMIT 0,8"); ?> <ul> <?php while($phdispart = $dispart->fetch(PDO::FETCH_ASSOC)){ echo '<li><a href="contentdetail.php?art_titleen='.$phdispart['art_titleen'].'"><h1>'.$phdispart['art_titlekh'].'</h1>'. substr($phdispart['art_detail'],0,100).'<p class="postdate">'.date("h:i a M j, Y ", strtotime($phdispart['art_postdate'])).'</p></a></li>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/273334-why-it-loop-3-times-per-article/ Share on other sites More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 I'd guess you have duplicate data. Quote Link to comment https://forums.phpfreaks.com/topic/273334-why-it-loop-3-times-per-article/#findComment-1406781 Share on other sites More sharing options...
Christian F. Posted January 19, 2013 Share Posted January 19, 2013 I reckon this is because of the JOIN, which you should be writing out properly, by the way. All to easy to make it a Cartesian product when writing it that way, not to mention it's a lot harder to read which increases the chances of bugs. So rewrite the query to use explicit (ANSI) JOINs, and then run it against the database manually. It should provide you with the reason why you're seeing what you're seeing. Quote Link to comment https://forums.phpfreaks.com/topic/273334-why-it-loop-3-times-per-article/#findComment-1406895 Share on other sites More sharing options...
catalankh Posted January 19, 2013 Author Share Posted January 19, 2013 i test my database on phpmyadmin SQL it work properly before i added into my code, and i double check my database it no doublication Quote Link to comment https://forums.phpfreaks.com/topic/273334-why-it-loop-3-times-per-article/#findComment-1406954 Share on other sites More sharing options...
PFMaBiSmAd Posted January 19, 2013 Share Posted January 19, 2013 (edited) What exactly is being displayed three times? I suspect that the code snippet you posted is inside of a loop that is causing everything, even the <ul>, to be repeated, and not just the < li > < /li > ? Edited January 19, 2013 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/273334-why-it-loop-3-times-per-article/#findComment-1406957 Share on other sites More sharing options...
catalankh Posted January 20, 2013 Author Share Posted January 20, 2013 you can see my print_r it exactly <ul> and repeated when i open the browser first time it work perfectly when i click on tablet then go back to phone it'll display 3 time loop ok let see the real link http://www.sabaychet.com/allnews.php?ph_sc_sub_name=phone you click the tablet at your right hand then click the second menu or the upper of tablet (it my language) u'll see it loop 3 time is it because of catch?? Quote Link to comment https://forums.phpfreaks.com/topic/273334-why-it-loop-3-times-per-article/#findComment-1407026 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.