Forum Moderators: coopster
Test1.com¦Real Estate¦.com¦100
Test2.net¦Real Estate¦.net¦200
travel1.org¦Travel¦.org¦200
Car2.com¦Cars¦.com¦500
I want to be able to display only let's say the real estate category. Below is the code i'm using, any help is greatly appreciated
</head>
<body>
<?php
echo '<h1>Flat File Database Sorted By <span class="sortby">'.$header.'</span></h1>
<p>To sort the columns click on the headers.</p>
<p>View the <a href="flat-file-data2.txt">database</a> or the <a href="flat-file-database-demo2.txt">PHP code</a> used.
<br /> </p>
<table summary="List of demo fields">
<tr>
<th><a href="?">Domain</a></th>
<th><a href="?category">Category</a></th>
<th><a href="?extention">Extention</a></th>
<th><a href="?price">Price</a></th>
</tr>';
$fp = fopen('flat-file-data2.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
while (!feof($fp)) {
$line = fgets($fp,1024); //use 2048 if very long lines
$row++;
list ($domain, $Category, $Extention, $Price) = split ('\¦', $line);
if ($sortby == 'domain') $sortkey = strtolower($domain);
if ($sortby == 'category') $sortkey = strtolower($Category);
if ($sortby == 'extention') $sortkey = strtolower($Extention);
if ($sortby == 'price') $sortkey = $Price;
$col[$row] = array($sortkey, $domain, $Category, $Extention, $Price, $car, $colour, $age);
}
fclose($fp);
sort($col);
reset ($col);
$arrays = count($col) - 1;
$loop = -1;
while ($loop < $arrays) {
$loop++;
echo '
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
</tr>';
}
echo '
</table>
<p><small>1 December 2004 · Last updated: '.date('j F Y', getlastmod()); ?> · A <a href="http://www.example.com">Example</a> production · <a href="http://www.example.com/archives/04/12/FlatFileDatabaseDemo2.php">About The Demo</a> · <a href="http://www.example.com/archives/04/12/FlatFileDatabaseDemo2.php#comments">Comments</a></small></p>
</body>
</html>
[edited by: eelixduppy at 6:16 pm (utc) on Mar. 28, 2009]
[edit reason] exemplified [/edit]