Jump to content
MakeWebGames

Help Me Please


lucky3809

Recommended Posts

I'am coding a new Comment mod, I got it done, however Im trying to add pagination to it, on the viewuser.php

and I can't seem to get it to work, what may I be doing wrong?

Here is what I got:

$limit = 5;
$page  = abs(@intval($_GET['page']));
$page  = isset($page) ? abs(@intval($_GET['page'])):0;
$by    = 'cTIME';
$order = 'DESC';
$rows  = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") ");
$rows  = mysql_num_rows($rows);
$pages = ceil($rows/$limit);
if($rows % $limit == 0)
{
$pages;
}
$pg = 'Pages:  ';
echo '
<form action="'.$_SERVER['PHP_SELF'].'" method="post">


'.$pg;
for($i = 1; $i <= $pages; $i++)
{
$next = ($i * $limit) - 5;
echo '[url="'.$_SERVER['PHP_SELF'].'?page='.$next.'"]'.$i.'[/url]';
}

 

Here are the query to the comment part:

$CC = mysql_query("SELECT c.`ID`,c.`cTIME`,c.`SenderID`,c.`RecieverID`,c.`Comment`,u.`userid`,u.`username` FROM `cComments` c LEFT JOIN `users` u "."ON c.`SenderID` = u.`userid` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") LIMIT ".$page.",".$limit." ");

 

If I add this to the end of the page part RecieverID = {$ir['userid']} ....instead of ....WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") ");... It works, only problem it shows EVERYONES comments I only want it to show that particular user comments, I got the page code from my mail, couldnt get the userlist one to work either. If someone can please help me lol. It's pissing me off I think I may have something wrong with the page count part.

 

Example this is on my viewuser page... trying to add pages I dont want my comments to be limited to show just 5, I want players to scroll through them by clicking pages...

commenta.png

Link to comment
Share on other sites

D.w mate i will post a view user later for you ?

I got a viewuser backup.

Ive added a comment mod to it below the sig, and trying to get pagination count on there so players can scroll through all comments instead of just seeing so many.

Forgot to mention Ive tried $r['userid'] instead of the $ir and get an error. I know $r is what im needing but it just wont take it, it gives an error in row

Link to comment
Share on other sites

change

$CC = mysql_query("SELECT c.`ID`,c.`cTIME`,c.`SenderID`,c.`RecieverID`,c.`Comment`,u.`userid`,u.`username` FROM `cComments` c LEFT JOIN `users` u "."ON c.`SenderID` = u.`userid` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") LIMIT ".$page.",".$limit." ");

to

$CC = $db->query("SELECT c.`ID`,c.`cTIME`,c.`SenderID`,c.`RecieverID`,c.`Comment`,u.`userid`,u.`username` FROM `cComments` c LEFT JOIN `users` u "."ON c.`SenderID` = u.`userid` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") LIMIT ".$page.",".$limit." ");

Link to comment
Share on other sites

I tried that, didnt work, I was able to click the page 1, but it said there was no comments posted, which should have showed the comments that was there.

This is what the error is

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/viewuser.php on line 366

This is line 366:

$rows = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") ");

Link to comment
Share on other sites

replace

$rows = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") ");

$rows = mysql_num_rows($rows);

$pages = ceil($rows/$limit);

if($rows % $limit == 0)

with

$comment = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") ");

$rows = mysql_num_rows($comment);

$pages = ceil($comment/$limit);

if($comment % $limit == 0)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...