Jump to content


Photo

HTML table formatting in PHP. Help?


  • Please log in to reply
6 replies to this topic

#1 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 10 August 2006 - 02:23 PM

Okay, I have my code pulling data from the database properly, BUT.... I can't seem to format it right for love or money. I'm good with HTML, so I initially just built an HTML table and then stuck my <?php......?> stuff inside the appropriate table section. Didn't work right.

What I'm trying now is:

<?php

print("<table border=10><tr><td>");

while($RESULT = mssql_fetch_assoc($RESULTDS)){

		echo $RESULT['Lmo'];
		echo "/";
		echo $RESULT['Lda'];
		echo "/";
		echo $RESULT['LYR'].'<br />';  

print("</td><td>");

		echo $RESULT['Leave Code'].'<br />';
}

		print("</td></tr></table>");

		?>

It comes out as:

Posted Image

What I want is Leave Date, Leave Type (code), and Hours across each column.

Anybody?

Thanks in advance!

EDIT: My semicolons aren't bumped down to the next line. It just did that when I pasted it here. As I didnt use the CODE tags.


#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 02:38 PM

So the first cell should contain a code, the date and some hours, not just the date as it does now? Where will you get the hours from?
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 10 August 2006 - 02:46 PM

So the first cell should contain a code, the date and some hours, not just the date as it does now? Where will you get the hours from?


From left to right, it should read: Date, Leave Type, Hours, then go to the next line and repeat. The Hours are a table in the database are there's no calculation involved in my code.


#4 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 02:55 PM

Just to be clear, you want Date in one cell, Leave Type in the next cell, Hours in the next cell, and then underneath that the next row, and so on?
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#5 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 10 August 2006 - 03:08 PM

Just to be clear, you want Date in one cell, Leave Type in the next cell, Hours in the next cell, and then underneath that the next row, and so on?


Exactly.

And thanks.



#6 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 03:15 PM

<?php

print("<table border=10>");

while($RESULT = mssql_fetch_assoc($RESULTDS)){

 echo "<tr>";

 echo "<td>";
 echo $RESULT['Leave Code'];
 echo "</td>";

 echo "<td>";
 echo $RESULT['Lmo'];
 echo "/";
 echo $RESULT['Lda'];
 echo "/";
 echo $RESULT['LYR'];  
 echo "</td>";

 echo "<td>";
 echo $RESULT['whatever your hours field is called'];
 echo "</td>";

 echo "</tr>";
}

 print("</table>");

?>

Try that.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#7 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 10 August 2006 - 03:22 PM

<?php

print("<table border=10>");

while($RESULT = mssql_fetch_assoc($RESULTDS)){

 echo "<tr>";

 echo "<td>";
 echo $RESULT['Leave Code'];
 echo "</td>";

 echo "<td>";
 echo $RESULT['Lmo'];
 echo "/";
 echo $RESULT['Lda'];
 echo "/";
 echo $RESULT['LYR'];  
 echo "</td>";

 echo "<td>";
 echo $RESULT['whatever your hours field is called'];
 echo "</td>";

 echo "</tr>";
}

 print("</table>");

?>

Try that.


Works!

You really ARE the king!

Thanks!

:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users