Jump to content

Recommended Posts

 

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>";
          }

 

Link to comment
https://forums.phpfreaks.com/topic/320682-span-rows-for-results/
Share on other sites

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).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.