nd3_2000 Posted August 13, 2009 Share Posted August 13, 2009 Hi guys, well the topic says it all! I need to find a way of getting my resultset to line next to one anohter, then after say the 4th or 5th result, drop down a line and start again. Hope someone can help here, relevant code is below - $sql = "SELECT * FROM Jobs where Print_Complete=0 and Print_Date=CURDATE()"; $results=mysql_db_query($database_name,$sql,$conn); echo "<h2>Today's Jobs for "; echo(Date("l F d, Y</h2>")); while ($output=mysql_fetch_array($results)) { echo "<h1><p><b>Job ID:</b>". $output['JobNo']; echo "<br /><b>Desc:</b> ". $output['Job_Desc']; echo "<br /><b>Print Date:</b> ". $output['Print_Date']; echo "<br /><b>Delivery Date:</b> ". $output['Delivery_Date']; echo "<br />"; ?> <a href="GetSingleJob.php?JobNumber=<?php echo $output['JobNo']; ?>">[View Job]</a> <?php echo "</h1><hr /></p>";} mysql_close($conn); ?> Quote Link to comment https://forums.phpfreaks.com/topic/170071-how-to-make-the-resultset-go-next-to-one-another-then-start-a-new-line-after-4/ Share on other sites More sharing options...
waterssaz Posted August 13, 2009 Share Posted August 13, 2009 add a counter??, along the lines of below but not tested :-) [code<?php $sql = "SELECT * FROM Jobs where Print_Complete=0 and Print_Date=CURDATE()"; $results=mysql_db_query($database_name,$sql,$conn); echo "<h2>Today's Jobs for "; echo(Date("l F d, Y</h2>")); $counter = 1; while ($output=mysql_fetch_array($results)) { if($counter == 5) { $spacer="<br><br>"; } else { $spacer=" ->"; } echo "<h1><p><b>Job ID:</b>". $output['JobNo']; echo "<br /><b>Desc:</b> ". $output['Job_Desc']; echo "<br /><b>Print Date:</b> ". $output['Print_Date']; echo "<br /><b>Delivery Date:</b> ". $output['Delivery_Date']."".$spacer."; ?> <a href="GetSingleJob.php?JobNumber=<?php echo $output['JobNo']; ?>">[View Job]</a> <?php $counter++; echo "</h1><hr /></p>";} mysql_close($conn); ?> Quote Link to comment https://forums.phpfreaks.com/topic/170071-how-to-make-the-resultset-go-next-to-one-another-then-start-a-new-line-after-4/#findComment-897172 Share on other sites More sharing options...
nd3_2000 Posted August 13, 2009 Author Share Posted August 13, 2009 Hi Wateressaz, cheers again for yesterday. Anyway that kinda worked, problem is, Im not getting the rows to be next to one another in the first place, it is putting the Breaks in ok I think in the right place but it is still making them come down underneath each ohter and not sure how to make them go next to each other in the first place! This is how I modified it so far $sql = "SELECT * FROM Jobs where Print_Complete=0 and Print_Date=CURDATE()"; $results=mysql_db_query($database_name,$sql,$conn); echo "<h2>Today's Jobs for "; echo(Date("l F d, Y</h2>")); $counter = 1; while ($output=mysql_fetch_array($results)) { if($counter == 5) { $spacer="</br>"; $counter = 1; } else { $spacer=""; } echo "<h1><p><b>Job ID:</b>". $output['JobNo']; echo "<br /><b>Desc:</b> ". $output['Job_Desc']; echo "<br /><b>Print Date:</b> ". $output['Print_Date']; echo "<br /><b>Delivery Date:</b> ". $output['Delivery_Date']; ?> <a href="GetSingleJob.php?JobNumber=<?php echo $output['JobNo']; ?>">[View Job]</a> <?php $counter++; echo "</h1><hr /></p>"."".$spacer."";} mysql_close($conn); ?> Quote Link to comment https://forums.phpfreaks.com/topic/170071-how-to-make-the-resultset-go-next-to-one-another-then-start-a-new-line-after-4/#findComment-897199 Share on other sites More sharing options...
waterssaz Posted August 13, 2009 Share Posted August 13, 2009 forgive my thickness :-) but can you elaborate on line next eachother. I need to find a way of getting my resultset to line next to one anohter, then after say the 4th or 5th result, drop down a line and start again. Do you mean that you want the job id, desc esc for each row along one line as per example below: Job id:4 , Desc:job 4, print date: 13/8/09, delivery date: 16/8/09 Job id:5 , Desc:job 5, print date: 13/8/09, delivery date: 17/8/09 etc and then after job 5 have a line break or like this: Job id:4 , Job id:5 , Desc:job 4, Desc:job 5, print date: 13/8/09 , print date: 13/8/09, delivery date: 16/8/09 delivery date: 17/8/09 etc.................. Quote Link to comment https://forums.phpfreaks.com/topic/170071-how-to-make-the-resultset-go-next-to-one-another-then-start-a-new-line-after-4/#findComment-897232 Share on other sites More sharing options...
nd3_2000 Posted August 13, 2009 Author Share Posted August 13, 2009 Like the second one sorry should have explained better Quote Link to comment https://forums.phpfreaks.com/topic/170071-how-to-make-the-resultset-go-next-to-one-another-then-start-a-new-line-after-4/#findComment-897289 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.