I have a php display script that takes data from a flat file db and transforms it into an array and then displays that info in a table. No problems with this.
Each line of data in the db contains 8 items. The first item is the genre or group identifier. For example:
cars|2001|Dodge|Blue
cars|2003|Chevy|Green
truck|2006|Dodge|Black
What I would like to do create a link to the display script. That link URL would contain or pass a variable (the genre / group identifier) to the display script that in turn displays only those items inside that genre or group.
The display script is below:
That is my dilemma.
Andy
Each line of data in the db contains 8 items. The first item is the genre or group identifier. For example:
cars|2001|Dodge|Blue
cars|2003|Chevy|Green
truck|2006|Dodge|Black
What I would like to do create a link to the display script. That link URL would contain or pass a variable (the genre / group identifier) to the display script that in turn displays only those items inside that genre or group.
The display script is below:
PHP Code:
<html>
<head>
<style>
.th{background:#ccdd88;}
.td{background:#fffff0;}
.tr{text-align:right;}
.tc{text-align:center;}
.pr{padding-right: 6px;}
.plr{padding-left:6px;padding-right:6px;}
.w1{width:100px;}
.w2{width:75px;}
.w3{width:400px}
</style>
<body>
<?php
///////////////////////////////////////////////////////////
//Here I assume I would declare the genre variable that is passed
//in the URL from the link ???
///////////////////////////////////////////////////////////
if(!file_exists("db_display_test.txt"))
{
echo"<center><b>NO RECORDS AT THIS TIME</center></b><br/>
<center>CHECK BACK LATER</center>";
exit;
}
echo"<table border=6 width=100% cellpadding=2 cellspacing=6>";
echo"<tr>";
echo"<th class='th plr'>Box 1</th>";
echo"<th class='th plr'>Box 2</th>";
echo"<th class='th plr'>Box 3</th>";
echo"<th class='th plr'>Box 4</th>";
echo"<th class='th plr'>Box 5</th>";
echo"<th class='th plr'>Box 6</th>";
echo"<th class='th plr'>Box 7</th>";
echo"</tr>";
//
$openedfile = fopen( "db_display_test.txt", 'r' );
if($openedfile)
{
while (!feof( $openedfile ) )
{
$line = trim(fgets( $openedfile ));
if ( !empty( $line ) )
{
list( $genre,$entry1,$entry2, $entry3, $entry4, $entry5, $entry6, $entry7) = explode( "|", $line );
/////////////////////////////////////////////////////////////
//What would go here to list only those entries that matched
//a specific genre?
////////////////////////////////////////////////////////////
echo"<tr>";
echo"<td class='td tc w2'>$entry1</td>";
echo"<td class='td tc w1'>$entry2</td>";
echo"<td class='td tc w2'>$entry3</td>";
echo"<td class='td tc w2'>$entry4</td>";
echo"<td class='td tc w2'>$entry5</td>";
echo"<td class='td tc w2'>$entry6</td>";
echo"<td class='td tc w2'>$entry7</td>";
echo"</tr>";
}
}
fclose( $openedfile );
}
else
{
echo"<tr>";
echo"<td class='th w3'>Cannot open file!</td>";
echo"</tr>";
echo"</table>";
}
?>
</BODY>
</HTML>
Andy
Comment