Steven
Steven

Reputation: 401

PHP- mysql query case issue

I have the following php and sql code, it works perfectly is the user has at least one of the 4 cases in tblactions. The problem occurs if the user only has 1 of the cases, for example attending. Then it seems to go on an infinite loop and the page won't load. Can anyone help me alter this code?

 $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>';


        }?> 

Upvotes: 0

Views: 124

Answers (1)

Dipesh Parmar
Dipesh Parmar

Reputation: 27364

This is the error.

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;

Forget to break attending case.

Upvotes: 2

Related Questions