Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building table labels based on values in php variable length

Status
Not open for further replies.

dreamaz

Technical User
Dec 18, 2002
184
CA
Sorry the subject's a little confusing, and I hope I explain this correctly.

I have a textfield which takes CSV data which then is split into arrays using explode(). My problem is that I need the labels at the top and the width needs to match the max width of each column data. Currently alll the data is displayed perfectly in tabled columns, but I need the titles at the top ie>

DATE TIME TYPE USERNAME TYPE FULLNAME etcc..


Here is what i have for my code:

<?php if(isset($_POST['feild1'])){
$stripped = str_replace("\r", ",", $_POST['feild1']);
$BREAK = explode(",", $stripped);

echo "<TR nowrap>";

$count=count($BREAK);

for ($i = 0; $i < $count; $i++) {

//if the count is greater than 28, then start a new table row

if (($i)%29==0)
{
echo "</TR><TR nowrap>";
echo "<TD><FONT SIZE=2>".$BREAK[$i]."</FONT></TD>";
}
else {
if (($i+1)%29==0)
{
echo "<TD><FONT SIZE=2>".$BREAK[$i]."</FONT></TD>";
}
else {
echo "<TD><FONT SIZE=2>&nbsp;&nbsp;".$BREAK[$i]."</FONT></TD>";
};
};
};

}
?>


</tr>

Any help is appreciated.

Thanks,

dR
 
have a look at the fgetcsv() function to return your data from a text file. providing your text file is properly formatted it should be a good start.
[link]
[/url]

there is a nice example for table output at the link above

for table styling, my a dvice is to start off removing all the style and similar declarations from the table, tr and td tags.this will cause the browser to render as best it can (so far as possible making the col width as small as it can to fit its content). then if you need greater control, use css to manage that control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top