我想要做的就是根据用户选择的等级来展示汽车。我有三张桌子,Classes,Cars和carclass。
类:
cID, Class Name, Price Range
汽车:
caID, Make, Model
carclass:
cID, caID, ccaID.
我想要的是,比如我输入一系列课程和汽车,如果我选择运动课,只有保时捷和法拉利显示,那么第四。
到目前为止,我只设法显示类,代码如下:
<?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>";
}
?>
在viewcars.php页面上,我不知道如何设置sql语句,有人可以帮帮我吗?
我尝试过以下但没有运气..
<?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;
}
?>
答案 0 :(得分:0)
在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;
}
?>