Hello all, I'm working on a comment script to produce a string of XML to be used for one of my ajax applications. However, I cannot figure out how to produce the xml. Assume that the passing of the parent_id variable is working for now.
Here's the code I'm using to export the XML.
<?php
$parent_id = $_GET['parent_id'];
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$comment_query = "SELECT * FROM comments WHERE parent_id = '$parent_id' ORDER BY post_time ASC";
$comment_data = mysqli_query($dbc, $comment_query);
$comment_rows = mysqli_fetch_array($comment_data);
xmlOutput = '<?xml version="1.0"?>';
xmlOutput .= '<comments>';
while($comment_rows){
xmlOutput .= '<comment>';
xmlOutput .= '<comment_id>'. $comment_rows['comment_id'] .'</comment_id>';
xmlOutput .= '<poster_id>'. $comment_rows['poster_id'] . '</poster_id>';
//Get username
$username_query = "SELECT username FROM wwit_user WHERE user_id = '$comment_rows['poster_id']'";
$username_data = mysqli_query($dbc, $username_query);
$username_rows = mysqli_fetch_array($username_data);
xmlOutput .= '<poster_name>'. $username_rows['username'] .'</poster_name>';
xmlOutput .= '<comment_text>'. $comment_rows['comment_text'] .'</comment_text>';
xmlOutput .= '<comment_time>'. $comment_rows['post_time'] .'</comment_time>';
xmlOutput .= '</comment>';
}
xmlOutput .= '</comments>';
header('Content-Type: application/xml;');
echo xmlOutput;
?>
Thanks!