
August 2nd, 2002, 08:08 PM
|
|
|
|
Join Date: Apr 2007
Location: Orlando, FL
Posts: 223
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
I updated Matt's News Feed, but...
I just updated Matt's news feed, but I'm having a problem. My requirements say I CANNOT use a database, so I'm going with flat text files. I only want to display the 5 most recent entires on the front page. The system is completely functional, but I don't like the way I'm getting the five posts. I've included, the code below, but the site can be seen and tried at http://firsttube.com/build - the password is "password" without quotes.
Can someone help me come up with something better than a session var to do this?
-Adam
php Code:
Original
- php Code |
|
|
|
<?php // create a new session // register a session-variable // Assign a value to the session-variable $newslimit = "0"; //news archive $archive = "allnews.php"; ?> <html> <center> <a href="admin.php"><font face=tahoma size=2>to admin</font></a><p> <table width=640> <?php echo "<TR><TH align=center bgcolor=#003366><font face=tahoma color=#c0c0c0 size=2>"; echo "Last 5 items submitted <a href=allnews.php>"; echo "<font color=white>(view news archive)</font></a>"; $data = file("news.txt"); foreach($data as $element) { $element = trim($element); $slashpieces = explode("|", $element); if ($newslimit < 5) { echo "<TR><td align=center bgcolor=#EFEFEF><font color=#000000 size=2 face=tahoma><b>" . $pieces[2]; echo "<td bgcolor=#c0c0c0 align=center><font size=2 color=#003366 face=tahoma>Posted by <B>"; echo "<a href=$archive?author=$fullname>" . $pieces[1] . "</a>"; echo "</b> on " . $pieces[0]; echo " in the <b><a href=$archive?showcat=$pieces[3]>" . $pieces[3] . "</a></b> categoryn"; $newslimit++; } ?> </table> </html>
|