azukah Posted August 13, 2011 Share Posted August 13, 2011 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 ("&","",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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/244701-php-as-xml-help-with-echoing/ Share on other sites More sharing options...
azukah Posted August 13, 2011 Author Share Posted August 13, 2011 I had my quotes all wrong .. fixed it ) <?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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/244701-php-as-xml-help-with-echoing/#findComment-1256892 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.