Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AJAX , jquery, Multi-Level Comments narrow results per page and replys 2

Status
Not open for further replies.

MAWarGod

Programmer
Feb 15, 2002
352
0
0
US
Hi I have been working with a script I found on a tutorial.

I would like to learn how to limit the parent posts per page..

and use a collapsed link to the reply after 3.. I have attached the script, I did find a tutorial that was more or less just a source code using livejquery.. but I can not seem to manage a relationship between the two scripts.


I would think I need a function some what like I found on this other scripting

Code:
<script type="text/javascript">

	// <![CDATA[	

	$(document).ready(function(){	
	
		$('.ViewComments').livequery("click",function(e){
			
			var parent  = $(this).parent();
			var getID   =  parent.attr('id').replace('collapsed-','');
			
			var total_comments = $("#totals-"+getID).val();
						
			$("#loader-"+getID).html('<img src="loader.gif" alt="" />');
			
			$.post("view_comments.php?postId="+getID+"&totals="+total_comments, {
	
			}, function(response){
				
				$('#CommentPosted'+getID).prepend($(response).fadeIn('slow'));
				$('#collapsed-'+getID).hide();
				
			});
		});




MA WarGod

I believe if someone can think it, it can be programmed
 
Code:
if(session_id() == '') session_start();
OK as You said I placed it at top of script, No I didn't have it there had it just before select


Code:
$offset = isset($_SESSION['curpage']) ? $_SESSION['curpage'] * 10 : 0;
$sql = <<<SQL

SELECT
    `id`,
    `name`,
    `url`,
    `pic`,
    `message`,
    `parent`,
    UNIX_TIMESTAMP(`date`) AS `date`
FROM mydb_table
ORDER BY UNIX_TIMESTAMP(`date`) ASC
LIMIT 10 OFFSET $offset
SQL;
is returning the last 10 results Thank You..
Now I am following the rest of you instructions above as far the button and java script..

jpadie thank You again for helping Me learn...

MA WarGod

I believe if someone can think it, it can be programmed
 
4. on delivery of the first page set the $_SESSION['curpage'] value to 1;

Has this changed now that that offset was made a $?

MA WarGod

I believe if someone can think it, it can be programmed
 
Nope. But depending on how you code the first and subsequent requests it may not matter

I can provide a solution that show the code but have not done so as I thi k you want to get through this yourself. If I have misinterpreted and code would be helpful then do let me know.
 
Hi jpadie I been playing with the script and I have a question

would the $_SESSION['curpage'] be enhanced (if this is possible) if I made the limit into a variable like $limit and assigned a array to it? or should the $_SESSION['curpage'] do the same? if some I am struggling but I am leaning how this effects the script lol..
its really kind of fun but I have allot of questions of why it does what it does when I change the 10 to say 2 or what every number I place there.. what I see is the limit, limits the gathering of data from the database's table and I think the $_SESSION['curpage'] acts as rendering the results of the limit that was set, So this is why I am wondering if its possible to create $limit array..

MA WarGod

I believe if someone can think it, it can be programmed
 
ok just answered my own question, I am forming it now I will post what I did..

MA WarGod

I believe if someone can think it, it can be programmed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top