Sorry this does not work, only return one result.
Let me try to explain a bit better..
my table (cars) has three fields:
model - make - line
example:
2002 BMW 760i - BMW - 1021
1983 525e - BMW - 1022
2004 BMW M5 - BMW - 1023
2004 BMW 525d - BMW - 1024
2004 BMW 630i - BMW - 1025
2004 Audi A6 3.2 FSI quattro - Audi - 1026
1952 Ferrari 250 MM - Ferrari - 1027
Using explode to extract "1022" from the url:
domain.com/cars.html/1022/
list($first) = explode('/', substr($PATH_INFO,1));
$first = 1022
I want to use $first to find the make, then use the make to extract all makes and display only the model
I have no idea how to make a cross-referencing query
within the same query using the same table.
example:
###########
list($first) = explode('/', substr($PATH_INFO,1));
$query = "SELECT *
FROM makes-model
WHERE line LIKE '$first'
LIMIT 1";
$result = mysql_query($query);
{
$make=mysql_result($result,$i,"make");
$model=mysql_result($result,$i,"model");
$line=mysql_result($result,$i,"line");
$query = "SELECT *
FROM makes-model
WHERE line LIKE '$make'
ORDER BY RAND() LIMIT 4";
echo "$model<br>";
}
output:
2004 BMW 630i
1983 525e
2004 BMW 525d
2004 BMW M5
###########
my syntax is fine for my server,
removing single quotes creates errors..