tags:

views:

77

answers:

3
$result = mysql_query("SELECT

  car.id     car_id,


FROM
    car

WHERE car.id= $id ");

How can I echo the query above?

+3  A: 

You're passing the query directly to the function. Store it in a variable if you want to echo it:

$query = "SELECT

  car.id     car_id,


FROM
    car

WHERE car.id= $id ";
echo $query;
$result = mysql_query($query);
Ignacio Vazquez-Abrams
thank you ignacio
jona
A: 

The above answer would echo the results of the query, if you simply want to echo the query string itself, store it as a string first, pass the string into the mysql_query function, and echo the string:

$sql = "SELECT car.id car_id, FROM car WHERE car.id= $id";
echo $sql;    
$result = mysql_query($sql);
Jen
Thank you guy for that info...
jona
+2  A: 
$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";
}
YetAnotherCoder
Thank you guy for that info...
jona