ebolt007 Posted February 10, 2012 Share Posted February 10, 2012 So I have a script I'm working on that pulls multiple comments from a database, then puts it in a jquery piece that pulls the data from the arrays I created in my MYSQL Select. Below is the results I get, and I want to combine the 2 queries because the information that I get is correct, however they are basically seperate arrays, hence the Undefined. I have something like that to get the arrays, $json = array_merge($names, $posts); return json_encode($json); and this is the result by using array_merge undefinedName1 undefinedName1 undefinedName1 undefinedName2 undefinedName2 Post1undefined Post1undefined Post1undefined Post2undefined Post3undefined Below if the javascript piece that I am using for this, can I split out the .html()? Because I have also done a bunch of unions and LEFT JOINS to my sql and can get most of the information I want into one array, but when I do this and try to echo the Posts, then it will echo the post 3 times instead of once if I have 3 comments, so I can't strip out the comments this way. Or is there a better way of doing this? Below is my javascript. $(document).ready(function(){ //settings on top var domain = 'http://test.com/'; var initialPosts = <?php echo get_posts(0,$_SESSION['posts_start']); ?>; //function that creates posts var postHandler = function(postsJSON) { $.each(postsJSON,function(i,post) { //post url var postURL = '' + domain + post.PostID; var id = 'post-' + post.PostID; //create the HTML $('<div></div>') .addClass('post') .attr('id',id) //generate the HTML .html('<tr><td>' + post.Name+ '' + post.Post+'</td></tr>') .click(function() { window.location = postURL; }) //inject into the container .appendTo($('#posts')) .hide() .slideDown(250,function() { if(i == 0) { $.scrollTo($('div#' + id)); } }); }); }; My biggest problem is only getting one post, but getting all the comments that were posted to this array doing it this way. Link to comment https://forums.phpfreaks.com/topic/256851-display-only-one-post-but-multiple-comments/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.