02-01-2008, 10:42 PM
|
#5 (permalink)
|
|
The Acquainted
Join Date: Jan 2008
Posts: 119
Thanks: 21
|
For right now I would. I know XML is the better choice, but I don't have the grasp yet on it to do this.
I have it working:
PHP Code:
<?php
$fp = fopen("comments.txt", "r+");
while(!feof($fp)){
$line_of_text = fgets($fp);
$parts = explode('||', $line_of_text);
echo "<h4>Road #: " . $parts[4] . "</h4> <span class='small'>Posted by: " . $parts[0] . "<br /> Date Posted: " . $parts[1] . "<br />" . "Location: " . $parts[3] . "</span><p><strong>Comments:</strong> " .$parts[5] . "</p>";
}
fclose($fp);
?>
However, onload, it gives me blank Road #: Posted by: etc... How can I get it to show nothing if the file is empty?
I have tried: if(!empty($file)){die}
But it doesn't work.
I would like it not to loop, unless there is at least 1 post.
|
|
|
|