hi all,
I've got an issue. I have and online profile system where people can register, login and post there car info and pictures online using a database. We'll the list is getting long and I'd like to split it up by model and year. And for some reason I'm having a brain fart tonight, and I also havent used php in about 2 months so im a bit rusty.
for example. There are many types of models that go into a certain group such as hatchback. Golf Gti, Golf, 337, and R32 are some of them that would be in the same group. After that I would like to separate the dates per body style. like 1980-1984, 1985-1992. etc. My problem is should I do this by calling the database every time. which would be about 50 times. OR sort it somehow after calling the entire table from the database?
I've been trying to think of a way to use PHP to sort if after but I can't get it right. The below code is the row that prints when it prints the entire list.
How can I have the $year array only have say years from 1980-1985 ahead echoing the list since.
while($query = mysql_fetch_array($result)) {
$user = $query["userid"];
$username = $query["username"];
$year = $query["year"];
$model = $query["model"];
$engine = $query["engine"];
$pic0 = $query["pic0"];
$numofrows = mysql_num_rows($result);
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<tr bgcolor=\"$row_color\">\n";
if ($pic0){ echo "<TD WIDTH=\"30\" ALIGN=\"CENTER\"><IMG SRC=\"images/cam.gif\" border=\"0\"></TD>\n"; }
else { echo "<TD WIDTH=\"30\"> </TD>\n"; }
echo "<TD WIDTH=\"150\">$username</TD>\n";
echo "<TD WIDTH=\"175\">$year $model $engine</TD>\n";
echo "<TD WIDTH=\"80\" ALIGN=\"CENTER\">";
if($searchyear OR $searchmodel OR $searchengine) {
echo "<A HREF=\"$PHP_SELF?action=view_record&user=$user&searchyear=$searchyear&searchmodel=$searchmodel&searchengine=$searchengine\"><strong>view profile</strong></A></TD>\n"; }
else { echo "<A HREF=\"$PHP_SELF?action=view_record&user=$user\"><strong>view profile</strong></A></TD>\n"; }
echo "</TR>\n";
$row_count++;
}