sql select查询无法正常工作,查看结果取决于所选内容

all I'm trying to do is display cars depending on the class the user has chosen. I have three tables, Classes, Cars and carclass.

Classes:

cID, Class Name, Price Range

Cars:

caID, Make, Model

carclass:

cID, caID, ccaID.

What I want is, say I enter a series of classes and cars, if I select the Sports class, only the Porsche and Ferrari to be displayed and so fourth.

So far I have only managed to display the classes, code is below:

<?php

$sql = "SELECT * from Class";
$result = mysql_query ($sql);
while ($class_detail = mysql_fetch_array ($result))
    {
     echo $class_detail["carClass"];
     echo "<a href = 'viewcars.php?cID=".$class_detail['cID']."'>View Cars</a>";
    }
?>

On the viewcars.php page, I have no idea how to set the sql statement, can someone help me please?

I have tried the following but no luck still..

<?php

$sql = "SELECT * from Class
WHERE caID in (
    SELECT caID FROM carclass
    WHERE cID = cID
    )";

$result = mysql_query ($sql);
while ($result_detail = mysql_fetch_array ($result))
    {
        echo $result;
    }
?>

Try this on viewcars.php:

<?php

$carid = $_GET['cID'];
$sql = "SELECT * from Class
WHERE cID = {$carid}";

$result = mysql_query ($sql);
while ($result_detail = mysql_fetch_array ($result))
{
    echo $result;
}
?>