问题描述:

I want to generate xml file from several tables in a MySQL database using PHP.

$query = "

SELECT

t.value,

d.value,

ty.value,

p.id,

p.ref,

p.is_renting,

p.price,

p.adress,

p.living_space,

p.rooms

FROM

jos_jea_properties p

INNER JOIN

jos_jea_towns t

ON

t.id = d.town_id

INNER JOIN

jos_jea_departments d

ON

d.id = p.department_id

INNER JOIN

jos_jea_types ty

ON

ty.id = p.type_id";

$result = mysql_query ($query, $link) or die("Could not complete database query");

But, it show me Could not complete database query, have you any idea?

网友答案:

There's something wrong in your query. Use mysql_error() to get the message returned by MySQL.

$result = mysql_query ($query, $link) or die("Could not complete database query: ".mysql_error())); 

However, your query gets a lot of fields named value. Use aliases instead, otherwise they're getting replaced

    $query = "SELECT t.value t_value, d.value d_value, ty.value ty_value, 
     p.id, p.ref, p.is_renting, p.price, p.adress, 
     p.living_space, p.rooms FROM jos_jea_properties 
     p INNER JOIN jos_jea_towns t ON t.id = d.town_id 
     INNER JOIN jos_jea_departments d ON d.id = p.department_id 
     INNER JOIN jos_jea_types ty ON ty.id = p.type_id"; 
网友答案:

Have you an idea about a code php How to generate a file xml for image since mysql database using php?

相关阅读:
Top