Jump to content

please hack this script for me...


slashpine

Recommended Posts

I am trying to add both column headings and alternating color rows to this script...can a php coder please code in an example of both in this script?

 

Thanks

<?php

$filename = "file.csv";

function viewlog($filename) {
$fp = fopen($filename,"r");
$file = fread($fp,65535);
$replaced = eregi_replace(",", "<td>", $file);
$replaced2 = eregi_replace("\n", "<tr><td>", $replaced);
$replaced3 = eregi_replace("\r", "<tr><td>", $replaced2);
fclose($fp);

return $replaced3;
}
echo "<html><head><title></title></head><body bgcolor=silver>";
echo "<table border=1 bordercolor=black cellspacing=0 cellpadding=5 width=100% style='font-size:10pt'>";

echo viewlog($filename);
echo "</table></body></html>";
exit;
?>

Link to comment
Share on other sites

Here is one way to do alternate row colors, not specific to your code, but easy to integrate.

 

$color = "#ffffff";
$color1 = "#ffffff";
$color2 = "#99ffff";
while ($row = mysql_fetch_row($result))
		{
		 			if ($color == $color1){
					$color = $color2;
					}ELSE{
					$color = $color1;
					}
					$id=$row[0];
					echo "<tr bgcolor=$color>";

Link to comment
Share on other sites

I am trying to add both column headings and alternating color rows to this script...can a php coder please code in an example of both in this script?

 

Thanks

<?php

$filename = "file.csv";

function viewlog($filename) {
$fp = fopen($filename,"r");
$file = fread($fp,65535);
$replaced = eregi_replace(",", "<td>", $file);
$replaced2 = eregi_replace("\n", "<tr><td>", $replaced);
$replaced3 = eregi_replace("\r", "<tr><td>", $replaced2);
fclose($fp);

return $replaced3;
}
echo "<html><head><title></title></head><body bgcolor=silver>";
echo "<table border=1 bordercolor=black cellspacing=0 cellpadding=5 width=100% style='font-size:10pt'>";

echo viewlog($filename);
echo "</table></body></html>";
exit;
?>

 

I have been able to add column headings but I am still unable to get the alternating row color to work

...can someone please show me hos this can be down witht the existing code?

 

Also...(more of a php question) how would I remove a couple of the records in the CSV file NOT to display?

 

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.