如何回应此查询?

时间:2010-02-17 04:34:10

标签: php sql

$result = mysql_query("SELECT

  car.id     car_id,


FROM
    car

WHERE car.id= $id ");

我如何回应上面的查询?

3 个答案:

答案 0 :(得分:3)

您将查询直接传递给该函数。如果要回显它,请将其存储在变量中:

$query = "SELECT

  car.id     car_id,


FROM
    car

WHERE car.id= $id ";
echo $query;
$result = mysql_query($query);

答案 1 :(得分:2)

$query = "SELECT car.id,car_id FROM car WHERE car.id= $id ";
$result = mysql_query($query)
while ($car_details = mysql_fetch_array($result)){
  echo "$car_details[id], $car_details[car_id]\n";
}

答案 2 :(得分:0)

如果您只想回显查询字符串本身,首先将其存储为字符串,将字符串传递给mysql_query函数,并回显字符串,上面的答案将回显查询结果:

$sql = "SELECT car.id car_id, FROM car WHERE car.id= $id";
echo $sql;    
$result = mysql_query($sql);