• 1 reply
  • Latest Post - ‏2012-02-16T16:57:50Z by ebolt007
3 Posts

Pinned topic What number system represents values using only 0s and 1s?

‏2012-02-16T16:48:40Z |
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.
CODE function get_posts($start = 0, $number_of_posts = 5) {
$posts = array();
$comments = array();
$query = "

FROM Users_WallPosts

WHERE Users_WallPosts.UserID = '$user_ID'

ORDER BY DateAdded DESC LIMIT $start,$number_of_posts";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
$posts[] = $row;

$postsmain = $row;

$sql2 = "
SELECT Users_WallComments.Comment FROM Users_WallComments
LEFT JOIN Users_WallPosts
ON Users_WallPosts.PostID = Users_WallComments.PostID
where Users_WallPosts.PostID = '$postsmain'";
$result2 = mysql_query($sql2);
while($comments_row = mysql_fetch_assoc($result2)) {
$comments[] = $comments_row;
return json_encode($posts);

Now I want it to pull those comments and posts in, I can get it to pull in one or the other, but I can't get the Posts to pull in, then the comments to pull in below that, basically like facebook. But I have this settup to only display so many comments then when you click the show more it loads more below the 5 so it doesn't load everything at the same time. I simplified my sql above, but the SQL's work fine, I'm good with PHP and sql, it's AJAX that I'm new too and confused with he below code. I'm guessing I need to json_encodes, and then use those, but how do I break these apart and use 2 json_encodes for my arrays above?

<script type="text/javascript">
//when the DOM is ready
//settings on top
var domain = '';
var initialPosts = <?php echo get_posts(0,$_SESSION); ?>;
//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

//generate the HTML
.html('<tr><td>' + post.Post + ''*then I want my comments to loop thru here like comments.Comment*'</td></tr>')

.click(function() {
window.location = postURL;
//inject into the container
.slideDown(250,function() {
if(i == 0) {
$.scrollTo($('div#' + id));
//place the initial posts in the page
//first, take care of the "load more"
//when someone clicks on the "load more" DIV
var start = <?php echo $_SESSION; ?>;
var desiredPosts = <?php echo $number_of_posts; ?>;
var loadMore = $('#load-more');
//load event / ajax{
//add the activate class and change the message
//begin the ajax attempt
url: 'indextest.php',
data: {
'start': start,
'desiredPosts': desiredPosts
type: 'get',
dataType: 'json',
cache: false,
success: function(responseJSON) {
//reset the message
loadMore.text('Load More');
//increment the current status
start += desiredPosts;
//add in the new posts
//failure class
error: function() {
//reset the message
loadMore.text('Oops! Try Again.');
//complete event
complete: function() {
//remove the spinner
Updated on 2012-02-16T16:57:50Z at 2012-02-16T16:57:50Z by ebolt007
  • ebolt007
    3 Posts

    Re: What number system represents values using only 0s and 1s?

    Sorry, somehow this got double posted from my other post and I don't see a delete post area.