djiles Posted August 1, 2007 Share Posted August 1, 2007 Hi, I am new to the site but I have been playing with php for a few months now, but I have yet to get a solid answer on why the code below does not work. I have written it as you see it but also as if, elseif, elseif, else and if, elseif, elseif, elseif. But no matter what happens the code goes funny on certain numbers. It will split rooms by 7774 or 7775 were it should do it by 7666 or 7766 Now if I move the if statements around it will change the outcomes, but it never does every one right. Any ideas? //4 Rooms if ($row > 24 && $row <= 32) { //Set limit $div = ($row / 4); $up = ceil($div); $down = floor($div); //Set room division if ($row = 25 || $row = 29) { $room1max = $up; $room2start = $up; $room2max = $down; $room3start = ($up + $down); $room3max = $down; $room4start = (($up + $down) + $down); $room4max = $down; } if ($row = 26 || $row = 30) { $room1max = $up; $room2start = $up; $room2max = $up; $room3start = ($up + $up); $room3max = $down; $room4start = (($up + $up) + $down); $room4max = $down; } if ($row = 27 || $row = 31) { $room1max = $up; $room2start = $up; $room2max = $up; $room3start = ($up + $up); $room3max = $up; $room4start = (($up + $up) + $up); $room4max = $down; } if ($row = 28 || $row = 32) { $room1max = $up; $room2start = $up; $room2max = $up; $room3start = ($up + $up); $room3max = $up; $room4start = (($up + $up) + $up); $room4max = $up; } //Room1 $query = mysql_query("SELECT * FROM Times ORDER BY GT, Min, Sec, Hun ASC LIMIT 0, $room1max"); echo '<tr>'; echo '<td align="center" colspan="2">Room 1</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="center">Gamertag</td>'; echo '<td align="center">Time</td>'; echo '</tr>'; while ($line = mysql_fetch_row($query)) { echo '<tr>'; echo '<td align="center">'.$line[0].'</td>'; echo '<td align="center">'.$line[1].':'.$line[2].'.'.$line[3].'</td>'; echo '</tr>'; } //Room2 $query1 = mysql_query("SELECT * FROM Times ORDER BY GT, Min, Sec, Hun ASC LIMIT $room2start, $room2max"); echo '<tr>'; echo '<td align="center" colspan="2">Room 2</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="center">Gamertag</td>'; echo '<td align="center">Time</td>'; echo '</tr>'; while ($line1 = mysql_fetch_row($query1)) { echo '<tr>'; echo '<td align="center">'.$line1[0].'</td>'; echo '<td align="center">'.$line1[1].':'.$line1[2].'.'.$line1[3].'</td>'; echo '</tr>'; } //Room3 $query2 = mysql_query("SELECT * FROM Times ORDER BY GT, Min, Sec, Hun ASC LIMIT $room3start, $room3max"); echo '<tr>'; echo '<td align="center" colspan="2">Room 3</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="center">Gamertag</td>'; echo '<td align="center">Time</td>'; echo '</tr>'; while ($line2 = mysql_fetch_row($query2)) { echo '<tr>'; echo '<td align="center">'.$line2[0].'</td>'; echo '<td align="center">'.$line2[1].':'.$line2[2].'.'.$line2[3].'</td>'; echo '</tr>'; } //Room4 $query3 = mysql_query("SELECT * FROM Times ORDER BY GT, Min, Sec, Hun ASC LIMIT $room4start, $room4max"); echo '<tr>'; echo '<td align="center" colspan="2">Room 4</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="center">Gamertag</td>'; echo '<td align="center">Time</td>'; echo '</tr>'; while ($line3 = mysql_fetch_row($query3)) { echo '<tr>'; echo '<td align="center">'.$line3[0].'</td>'; echo '<td align="center">'.$line3[1].':'.$line3[2].'.'.$line3[3].'</td>'; echo '</tr>'; } } Quote Link to comment https://forums.phpfreaks.com/topic/62929-solved-strange-results-from-if-elseif-and-else-statements/ Share on other sites More sharing options...
teng84 Posted August 1, 2007 Share Posted August 1, 2007 use double == or === in your if statement i found out that you only use single = which is for assignation Quote Link to comment https://forums.phpfreaks.com/topic/62929-solved-strange-results-from-if-elseif-and-else-statements/#findComment-313450 Share on other sites More sharing options...
djiles Posted August 2, 2007 Author Share Posted August 2, 2007 Thank you so much. I have asked this question in many a forums, with no good answer. Quote Link to comment https://forums.phpfreaks.com/topic/62929-solved-strange-results-from-if-elseif-and-else-statements/#findComment-314002 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.