Tuesday, April 28, 2009

[jQuery] Please Help - While Loop PHP & JSON - Comment List

I want to display an unordered list of comments from my echoed JSON
result using this jQuery code block:

$("#goComment").click(function(){

bigComment = $("#bigComment").val();

$.post("i-upComments.php", { //this inserts the comment
into the 'comments' table in the DB

bigComment: bigComment,
u: u,

}, function(data){

//display the list of comments as a unordered list - LI

});

});

-----------------
Here is my PHP:

<?php

include_once("db.php");

$u = 'Jl6XR';

$sql = "SELECT * FROM bigNest INNER JOIN comments ON comments.u =
bigNest.uid";

$result = mysql_query($sql);

while($array = mysql_fetch_array($result)) {

$bigtitle = $array[bigtitle];
$bigbody = $array[bigbody];
$comments = $array[comments];
}

$val = array("bigtitle" => $bigtitle,
"bigbody" => $bigbody,
"comments" => $comments,

);

$output = json_encode($val);
echo $output."\n";


?>

No comments: