Jump to content

HTML table formatting in PHP. Help?


Moron

Recommended Posts

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:

[code]<?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>");

?>[/code]

It comes out as:

[img]http://mywebpages.comcast.net/techie4/formatting.gif[/img]

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 [b]CODE[/b] tags.
Link to comment
Share on other sites

[quote author=king arthur link=topic=103720.msg413215#msg413215 date=1155220685]
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?
[/quote]

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.
Link to comment
Share on other sites

[quote author=king arthur link=topic=103720.msg413230#msg413230 date=1155221733]
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?
[/quote]

Exactly.

And thanks.

Link to comment
Share on other sites

[code]
<?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>");

?>
[/code]

Try that.
Link to comment
Share on other sites

[quote author=king arthur link=topic=103720.msg413249#msg413249 date=1155222915]
[code]
<?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>");

?>
[/code]

Try that.
[/quote]

Works!

You really ARE the king!

Thanks!

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