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!

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.