Hi,
Im wanting to create a simple flat file database for s friends site. She needs to be able to add and delete her tourdates as needed.
It only needs a few fields:
date|venue|town|country
I found a tutorial that allowed me to take info in the format above and print the rows out. But does anyone know the best way to add to and delete from the flat file? should i use a "Primary Key" type thing as you would use with MySql? (I would use MySql but her server sucks so just wanting to use the flat file method)
And if she was to add a date that fell before dates she had put in before, how could i sort it so that the dates go from now until the last date entered?
This is the little piece of code i found:
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="1%"><strong>Date</strong></td>
<td> <strong>Venue</strong></td>
<td><strong>City</strong></td>
<td width="1%"><strong>Country</strong></td>
</tr>
<?php
$fp = fopen('tourdates.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.'; exit;}
while (!feof($fp)) {
$line = fgets($fp, 1024); //use 2048 if very long lines
list ($field1, $field2, $field3, $field4) = split ('\|', $line);
echo '
<tr>
<td nowrap>'.$field1.'</td>
<td> '.$field2.'</td>
<td>'.$field3.'</td>
<td>'.$field4.'</td>
</tr>';
$fp++;
}
fclose($fp);
?>
</table>
Any links to turials would be cool, or some other direction.
Thanks,
Danny