adzie Posted May 13 Share Posted May 13 Hey all, My challenge is to get each <TD> to span multiple rows but I've declared the <TD> already after resource as $rft Any work arounds? <?php foreach($resource as $rft) { echo "<td>"; $abc = $rft['id']; $sqlb = "select * from bookings where resource = $abc"; foreach($sqlb2 as $rb2) { $str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", date('H:i:s', strtotime($rb2['start']))); sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds); $time_seconds3 = $hours * 3600 + $minutes * 60 + $seconds; $str_time2 = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", date('H:i:s', strtotime($rb2['end']))); sscanf($str_time2, "%d:%d:%d", $hours, $minutes, $seconds); $time_seconds4 = $hours * 3600 + $minutes * 60 + $seconds; $bkg = ($time_seconds4 - $time_seconds3) / 1800; if($time_seconds3 == $t7) { echo "Booked: Thursday, 25 April 2024 - 13:05"; } } echo "</td>"; } Quote Link to comment https://forums.phpfreaks.com/topic/320682-span-rows-for-results/ Share on other sites More sharing options...
maxxd Posted May 13 Share Posted May 13 First and foremost, don't run the query in a loop. Chances are you can use a join to get a full dataset before you begin your loop. The other benefit of doing this is that your data will more than likely present itself in a way that makes what you're trying to do easier. Can't help you with how to do that as we don't have all the code and what we do have is clearly not the actual code (there's no $sqlb2 for you to loop over in what you've posted). Quote Link to comment https://forums.phpfreaks.com/topic/320682-span-rows-for-results/#findComment-1624074 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.