Jump to content

How to make the resultset go next to one another then start a new line after 4


nd3_2000

Recommended Posts

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

?>

Link to comment
Share on other sites

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);
?> 

 

Link to comment
Share on other sites

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

?>

Link to comment
Share on other sites

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

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.