cjohnsonuk Posted October 13, 2009 Share Posted October 13, 2009 I found the tutorial on the joins. I can read my location, room and help desk call information into one array but is there an elegant way to display the resulting parsed array nicely into 1 div per location and 1 table per room with each call going in on its own table row? Link to comment https://forums.phpfreaks.com/topic/177602-how-to-identify-location-and-room-changes-an-elegant-solution/ Share on other sites More sharing options...
Alt_F4 Posted October 14, 2009 Share Posted October 14, 2009 Without much to go on its a bit difficult to know what you want to achieve. I'm going to take a stab anyway <?php $sql = "SELECT * FROM sometable"; $query = mysql_query($sql); $loc = ''; //set temp variable to hold location $room = ''; //set temp variable to hold room while($result = mysql_fetch_array($query)) { //check if location has changed if($loc != $result['location']) { if($loc == '') { //first time through the loop - open a new div tag echo '<div>'; } else { //close the existing div tag and open a new one echo '</div><div>'; } } if($room != $result['room']) { if($room == '') { //first time through the loop - open a new table tag echo '<table>'; } else { //close the existing table tag and open a new one echo '</table><table>'; } } //display the calls echo '<tr><td>'.$result['call'].'</td></tr>'; //update temp variables $loc = $result['location']; $room = $reslt['room']; } ?> i haven't fully tested this yet, but it should give you what i think you want :-\ Can you post the query that you have and some html on how you expect it to look, in case the above is not what you want. Link to comment https://forums.phpfreaks.com/topic/177602-how-to-identify-location-and-room-changes-an-elegant-solution/#findComment-936469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.