Jump to content

PHP as XML help with echoing...


azukah

Recommended Posts

i'm trying to get this php file show as xml and... the echo part is not coming up correct. it all comes as one thing instead of 3 attributes

<item review='.$subject.' desc='.$short_description.' img='.$review_img.'/>

 

 

here's teh complete code...

<?php
require_once('cms/config.php');
mysql_select_db($database, $makeconnection);
$sql_get_reviews = "SELECT * 
FROM tbl_reviews 
WHERE review_pending='0'
ORDER BY review_stamp DESC LIMIT 7";
$get_reviews = mysql_query($sql_get_reviews, $makeconnection) or die(mysql_error());
$row_get_reviews = mysql_fetch_assoc($get_reviews);
$totalRows_get_reviews = mysql_num_rows($get_reviews);
echo
'<?xml version="1.0" encoding="UTF-8"?>
<xmlList err="0" str="">';

do {     
$subject = $row_get_reviews['review_shampoo'].' reviewed by '.$row_get_reviews['review_author'];
$description = $row_get_reviews['review_desc'];
$description = str_replace ("&amp","",htmlspecialchars(strip_tags($description))); //clean the description
$short_description = substr($description,5) . "...";
$review_img = $row_get_reviews['review_img'];
;
echo
'
	<item review='.$subject.' desc='.$short_description.' img='.$review_img.'/>
';
}while ($row_get_reviews = mysql_fetch_assoc($get_reviews)); 
mysql_close(); 
echo '</xmlList>';
?>

Link to comment
https://forums.phpfreaks.com/topic/244701-php-as-xml-help-with-echoing/
Share on other sites

I had my quotes all wrong .. fixed it :)) :D

 

<?php
require('cms/config.php');
mysql_select_db($database, $makeconnection);
$sql_get_reviews = "SELECT * 
FROM tbl_reviews 
WHERE review_pending='0'
ORDER BY review_stamp DESC LIMIT 7";
$get_reviews = mysql_query($sql_get_reviews, $makeconnection) or die(mysql_error());
$row_get_reviews = mysql_fetch_assoc($get_reviews);
$totalRows_get_reviews = mysql_num_rows($get_reviews);
echo
'<?xml version="1.0" encoding="UTF-8"?>
<xmlList err="0" str="">';

do {     
$name = $row_get_reviews['review_shampoo'];
$type = $row_get_reviews['review_brand'];
$img = $row_get_reviews['review_img'];
;
echo
'<item review="'.$name.'" desc="'.$type.'" img="'.$img.'"/>';

}while ($row_get_reviews = mysql_fetch_assoc($get_reviews)); 
mysql_close(); 
echo '</xmlList>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.