Hi thanks I've create xml using MySQL and php, but i need to select paticular rows from my data base I'v try using WHERE in my query but this is not working can you help here is my code:
//
[code=php]<?php
header("Content-type:text/xml");
$con=mysql_conn ect("localhost" ,"userrname","p assword")or die(mysql_error ());
mysql_select_db ("database",$co n);
$query ="SELECT*FRO M male WHERE Imagename ='$glog ORDER BY imagename ASC";
$resultID=mysql _query($query, $con) or die("Data not found.");
$xml_output="<? xml version=\"1.0\" ?>\n";
$xml_output.="< products title='Product' >\n";
for($x = 0 ; $x < mysql_num_rows( $resultID) ; $x++){
$row = mysql_fetch_ass oc($resultID);
$xml_output .= "\t<InSert itemdiscription ='$row[name]'>\n";
$xml_output .= "\t<id ident='$row[iddent]'></id>\n";
$xml_output .= "\t<Size gs='$row[size]'></Size>\n";
$xml_output .= "\t<Price gp='$row[price]'></Price>\n";
$xml_output .= "\t<Quantit y gq='$row[quantity]'></Quantity>\n";
$xml_output .= "\t<Discrip tion gd='$row[discription]'></Discription>\n" ;
$xml_output .= "\t<Imagena me gi='$row[imagename]'></Imagename>\n";
$xml_output .= "\t</InSert>\n";
}
$xml_output .= "</products>";
echo $xml_output;
?>[/code]
kind regard Zar
Last edited by ak1dnar; Jul 31 '07, 03:32 PM.
Reason: added Code tags
The code is for a flash site which has already been made so i have to reflect who the old XML code was whiten: here is the display. Hope you can help
Zar
Hi thanks I've create xml using MySQL and php, but i need to select paticular rows from my data base I'v try using WHERE in my query but this is not working can you help here is my code:
//
[code=php]$query ="SELECT*FRO M male WHERE Imagename ='$glog ORDER BY imagename ASC";
[/code]
I might try spacing things out in your query, don't know if this is exactly how you have it written in your code, but it seems cramped to me. You also have a single quote left out after the $glog variable. I would rewrite like this:
[PHP]$query = "SELECT * FROM male WHERE Imagename = '$glog' ORDER BY imagename ASC;"[/PHP]
Also, does the "male" table have two fields named imagename, one lower case and one upper case as you have it written in your query. If so you (I don't even thing you can do that in mysql), you may want to think about your table structures again. Also, your ordering by the same field specified in the Where clause, which means they are all going to be the same, thus you can't reorder them. Seems pointless to me....
I might try spacing things out in your query, don't know if this is exactly how you have it written in your code, but it seems cramped to me. You also have a single quote left out after the $glog variable. I would rewrite like this:
[PHP]$query = "SELECT * FROM male WHERE Imagename = '$glog' ORDER BY imagename ASC;"[/PHP]
Greg,
you are absolutely correct. I think I also missed the single quote in the original post.
but, to the best of my knowledge this kind of MYSQL queries are executing perfectly.
Comment