Jump to content

Php Xml


wewewe14

Recommended Posts

hello, i want make xml.php file likes http://gosale.ge/xml.php with php xml

this is my code but it dont like this while($row = mysql_fetch_array($rs))

{

 

$id = $row['id'];

$name=$row['name'];

$image=$row['pic_dir'];

$text=$row['id'];

$time=$row['end_at'];

$price=$row['price'];

$percent= 100-(($row['price']*100)/$row['origin_price']);

$price=$row['price'];

 

$xml_output .= "<sale >\n";

$xml_output .= "<link>http://hopla.ge/component/enmasse/deal/view/$id/1960_28_1_.html</link>\n";

$xml_output .= "<title>$title</title>\n";

$xml_output .= "<image>2222</image>\n";

$xml_output .= "<text>$text</text>\n";

$xml_output .= "<price>$price</price>\n";

$xml_output .= "<percent>$percent</percent>\n";

$xml_output .= "</url>\n";

 

}

 

$xml_output .= "</deals>";

 

echo $xml_output;

 

can anybody help me?

Link to comment
Share on other sites

This is a fine way to do it. You are just not rendering proper XML, so that is probably why it is not showing up properly.

 


$xml_output = '<?xml version="1.0" encoding="UTF-8"?><deals>';

while ($row = mysql_fetch_array($rs)) {
$xml_output .= "<sale id=\"$id\">";
$xml_output .= "<link>http://hopla.ge/comp...html</link>";
$xml_output .= "<title>$title</title>";
$xml_output .= "<image>2222</image>";
$xml_output .= "<text>$text</text>";
$xml_output .= "<price>$price</price>";
$xml_output .= "<percent>$percent</percent>";
$xml_output .= "</url>";
$xml_output .= "</sale>"; // You were missing this
}

$xml_output .= "</deals>";

echo $xml_output;

 

You say that you don't "like that". Why not? If you are fetching rows from a database, then you will have to loop through them regardless. I am not exactly sure what the problem is?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.