Jump to content

Parsing a flatfile database..should be easy help please!


jk215

Recommended Posts

Hi everyone. Im working with a flatfile database text file and was wondering if anyone might be able to help me out with what I want to accomplish. Basically the .txt is a listing of events that my work shows everyday. I have everything working perfectly so far with outputting the data. Here is my code (please be nice Im not a real programmer  ;D ):

 

<div id="downstairsshows"> 

<?
$fp = fopen('downstairs.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.'; exit;}

$counter = 1;

while ($counter <= 6) {
$line = fgets($fp, 1024); //use 2048 if very long lines
list ($dayofweek, $month, $daynumber, $presents, $showtitle, $with, $ticketlink, $thumbnail) = split ('\|', $line);

$thumbnail = '<img src="images/thumbnails/'.$thumbnail.'" '.'width="50px" height="50px" alt="'.$showtitle.'" /> <br />'."\n";

echo '<div class="showlisting">';
echo '<div class="thumbnailcontainer">';
echo $thumbnail;
echo '</div>';
echo '<div class="listingdetails">';
echo '<span class="bold">'.$dayofweek . ', ' . $month .' '. $daynumber . '</span><br />'."\n";
echo $presents . '<a href="'.$ticketlink.'"> '.'<h2>'.$showtitle.'</h2>'.'</a><br />'."\n";
echo $with . '<br />'."\n";
echo '</div>';
echo '</div>';
$counter++;

}

fclose($fp);

?>
</div>                         

 

 

So basically its just running through the lines and outputting them as a listing on the webpage and people can click to purchase tickets. My question is, can I add some sort of conditional statement that would check todays date from the server, match it up against the date of the show thats being listed, and decide whether or not to display it? For instance if its November 7, the output would skip all the listings that are before November 7 and just loop the next 6 shows starting from there. Sorry if that doesnt seem very clear. Basically I just want to load all the dates for a month or so into the flatfile and have it automatically output the dates coming up and ignore dates already posted. Im pretty sure I should be using a mysql database for this but Ive been having a load of trouble with it because my company is using shitty Yahoo Small Business hosting. Any help is appreciated!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.