2013-02-12 50 views
0

我有以下的PHP和SQL代碼,它完美的作品是用戶擁有的4例tblactions至少一個。如果用戶只有一個案例出現問題,例如參加。然後,它似乎進入無限循環,頁面將無法加載。任何人都可以幫我改變這段代碼嗎?PHP的MySQL查詢案件問題

$result5 = mysql_query("SELECT tblactions.*, fgusers.username FROM tblactions LEFT JOIN fgusers ON fgusers.id_user = tblactions.following_id WHERE user_id = '$test' ORDER BY timestamp DESC") 

    while ($row5 = mysql_fetch_array($result5)) 
    { 
     $actiontype = $row5['type']; 
     switch ($actiontype) 
    { 
    case "event": 

     echo '<div id="peepme" class="ui-btn-text">', 
      '<img id="peoplemeimg" alt="Happps" src="image/'.$row7['photo'].'" class="ui-li-thumb">', 
      '<h3 id="pmh3" class="ui-li-heading">',$row5['user_name'], ' created the event','</h3>', 
      '<a id="pmevent" data-ajax="false" class="ui-li-heading" href="eventview.php?eventid='.$row5['event_id'].'">',$row5['event_name'],'</a>', 

      '</div>'; 
     break; 

    case "follow": 

     echo '<div id="peepme" class="ui-btn-text">', 
      '<img id="peoplemeimg" alt="Happps" src="image/'.$row7['photo'].'" class="ui-li-thumb">', 
      '<h3 id="pmh3" class="ui-li-heading">',$row9['username'], ' started following','</h3>', 
      '<a id="pmevent" data-ajax="false" class="ui-li-heading" href="people.php?id='.$row5['following_id'].'">',$row5['username'],'</a>', 

      '</div>'; 

     break; 

    case "photo": 

    echo '<div id="peepme" class="ui-btn-text">', 
     '<img id="peoplemeimg" alt="Happps" src="image/'.$row7['photo'].'" class="ui-li-thumb">', 
     '<h3 id="pmh3" class="ui-li-heading">',$row9['username'], ' uploaded a photo','</h3>', 
     '<div id="imgupld">','<img id="upldimg" alt="Happps" src="image/'.$row5['photo'].'" class="ui-li-thumb">', 

     '</div>',     
     '</div>'; 

     break; 

    case "attending": 

    echo '<div id="peepme" class="ui-btn-text">', 

     '<img id="peoplemeimg" alt="Happps" src="image/'.$row7['photo'].'" class="ui-li-thumb">', 
     '<h3 id="pmh3" class="ui-li-heading">',$row9['username'], ' is attending ','</h3>', 
     '<a id="pmevent" data-ajax="false" class="ui-li-heading" href="eventview.php?eventid='.$row5['event_id'].'">','This Event','</a>', 

     '</div>'; 


     }?> 
+2

你似乎錯過了'while' – 2013-02-12 04:04:43

+0

,你也忘了在出院時增加休息時間...... – 2013-02-12 04:12:02

+0

@steven reda,Dipesh Parmar和Explosion Pills是正確的,緊挨着大括號。 – 2013-02-12 04:12:32

回答

2

這是錯誤。

case "attending": 

echo '<div id="peepme" class="ui-btn-text">', 

     '<img id="peoplemeimg" alt="Happps" src="image/'.$row7['photo'].'" class="ui-li-thumb">', 
     '<h3 id="pmh3" class="ui-li-heading">',$row9['username'], ' is attending ','</h3>', 
     '<a id="pmevent" data-ajax="false" class="ui-li-heading" href="eventview.php?eventid='.$row5['event_id'].'">','This Event','</a>', 
    '</div>'; 

break;

忘記參加案件。

+0

不錯的抓...好回答。 – 2013-02-12 04:15:15

+0

謝謝,猜太久,我看着它。 – Steven 2013-02-12 04:43:18

+0

您隨時歡迎兄弟。 – 2013-02-12 04:44:49