SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    49
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Question why it loop 3 times per article?

    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 )
    PHP Code:
     $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>';
        }
    ?>
    what problem please help

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Have you looked at your database to make sure the article isnt in there three times?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    49
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i double check my database it no doublication any way i test my query in phpmyadmin SQL before i added it into my code

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    So you have only one article with sub_name "phone"? I get the impression you havent designed your query the way you think you have.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    49
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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...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??

  6. #6
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hengwebdeveloper View Post
    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...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??
    I dont see that at all. I see one.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    49
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thank StarLion i solved it problem now i found the new problem i'll post it in new topic now

  8. #8
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Code:
    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
    Paste that query directly into your database (using PHPMyAdmin or whatever you use to manage your LIVE database, and see, does it return 3 rows?

    If no, then its likely a PHP problem, if yes, then it looks as though the JOIN you are evoking might need a GROUP BY cause.

    I think its unlikely, as your LOCAL database does not do this, you say.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •