Jump to content

php forum page problems???


DEViANCE

Recommended Posts

Hi, i have been working with a wap forum script, translating from russian and fixing errors etc.. but now im stuck, the problem is with the pages while viewing a forum..

 

Let me explain.. the pages are set to show ten topics per page which all works fine as you can see in these screenshots:

 

page 1:

wappagesok1.png

 

page 2:

wappagesok2.png

 

The problem occurs when there are PINNED topics (with the redish folder), it will show ten topics but also the pinned ones on page one, and the "Next" link will appear before it should leading to a blank page where there should be topics but they are still on the other page lol..

 

Here is a screenshot of the pages not working with pinned topics..

 

page1:

wappagesnotok1.png

 

page2:

wappagesnotok2.png

 

Now here is the two bits of code relating to it:

 

part 1:

function getposts($id,$nick,$pass,$page)

{

slogin($nick,$pass);

global $banned;

//  $letssee=false;

if (!$banned) {

$page=$page-1;

if (!$page==0) $page=$page*10; else $page=0;

$pagemore=$page+10;

$pinnedposts=mysql_query("SELECT id, name FROM posts WHERE forum='".$id."' AND thread='1' AND pinned='1' ORDER BY position LIMIT ".$page.",5");

$kiekpinnintu=mysql_num_rows($pinnedposts);

$ikipage=10-$kiekpinnintu;

if ($ikipage<0) $ikipage=0;

$userposts=mysql_query("SELECT id, name FROM posts WHERE forum='".$id."' AND thread='1' AND pinned='0' ORDER BY position LIMIT ".$page.",10");

echo "<br/>";

while ($rowas = mysql_fetch_array($pinnedposts))

{

$isclosed=mysql_fetch_array(mysql_query("SELECT closed FROM posts WHERE name='".$rowas[1]."' AND forum='".$id."'"));

$postu=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM posts WHERE forum='".$id."' AND name='".$rowas[1]."'"));

$rowas[1]=htmlspecialchars($rowas[1]);

$enc=urlencode($rowas[1]);

$enc=htmlspecialchars($enc);

$image="<img src=\"images/pinned.gif\" alt=\"*\"/>";

if ($isclosed[0]==1) {$image="<img src=\"images/closed.gif\" alt=\"*\"/>";}

echo "<a href=\"index.php?action=viewpost&name=$enc&nick=$nick&pass=$pass&forumas=$id&read=old&page=1\">$image$rowas[1](".$postu[0].")</a>"; echo "<br/>";

}

while ($rowas = mysql_fetch_array($userposts))

{

$isclosed=mysql_fetch_array(mysql_query("SELECT closed FROM posts WHERE name='".$rowas[1]."' AND forum='".$id."'"));

$postu=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM posts WHERE forum='".$id."' AND name='".$rowas[1]."'"));

$rowas[1]=htmlspecialchars($rowas[1]);

$enc=urlencode($rowas[1]);

$enc=htmlspecialchars($enc);

//$viewpost_title =convert_cyr_string($rowas[1],"i","w");

if ($postu[0]>20) {

$image="<img src=\"images/hot.gif\" alt=\"*\"/>";

} else {$image="<img src=\"images/normal.gif\" alt=\"*\"/>";}

if ($isclosed[0]==1) {$image="<img src=\"images/closed.gif\" alt=\"*\"/>";}

echo "<a href=\"index.php?action=viewpost&name=$enc&nick=$nick&pass=$pass&forumas=$id&read=old&page=1\">$image$rowas[1](".$postu[0].")</a>"; echo "<br/>";

}

echo "<br/>";

} else echo "Your Banned!";

}

 

part2:

if ($action=="viewforum")		   {							 //let's have a look @ forum

$forumnameasasas=mysql_fetch_array(mysql_query("SELECT name FROM forums WHERE id='".$id."'"));

echo "<card id=\"viewforum\" title=\"$forumnameasasas[0]\">";

echo "<p align=\"center\">";

global $timezone;

$valandos=date("H")+$timezone;

if ($valandos>23) $valandos=$valandos-24;

$data=date("y m d - ".$valandos.":i");

echo "$data<br/>";

echo ismod($nick,$pass,$id);

global $moderator;

if ($moderator) echo "Welcome Moderator!<br/>";

$letssee=false;

$fperms=mysql_fetch_array(mysql_query("SELECT perms FROM forums WHERE id='".$id."'"));



if ($fperms[0]=="0") {$letssee=true;}

if ($fperms[0]=="1") {$letssee=true;}

if ($fperms[0]=="2") {

$forribdforums=mysql_query("SELECT forum FROM permissions WHERE name='".$nick."'");

while ($frumas=mysql_fetch_array($forribdforums)) {

if ($frumas[0]==$id or $frumas[0]=="*") {

$letssee=true;

}}

}



if ($letssee) {

echo "<a href=\"index.php?action=newthread&id=$id&nick=$nick&pass=$pass\">New Topic</a>";

//echo "<br/>";

echo "</p><p align=\"left\">";

echo getposts($id,$nick,$pass,$page);

echo "</p><p align=\"center\">";

$page=$page+1;

$poststot=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM posts WHERE forum='".$id."' AND thread='1'"));

$poststot[0]=$poststot[0];

//echo "<br/>";

$poststot=ceil($poststot[0]/10);

if ($page<$poststot+1) echo "<a href=\"index.php?action=viewforum&id=$id&nick=$nick&pass=$pass&page=$page\">Next</a><br/>";

$page=$page-2;

if ($page>0) echo "<a href=\"index.php?action=viewforum&id=$id&nick=$nick&pass=$pass&page=$page\">Prev</a><br/>";

$page=$page+1;

if ($poststot==0) $poststot=1;

echo slogin($nick,$pass);

global $logged;

if ($logged) {

$unreadinbox=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM private WHERE unread='y' AND sentto='".$nick."'"));

if ($unreadinbox[0]>0) {

$pmtotl=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM private WHERE sentto='".strtolower($nick)."'"));

$unrd="(".$unreadinbox[0]."/".$pmtotl[0].")";

echo "<a href=\"index.php?action=private&nick=$nick&pass=$pass&page=1\">Inbox$unrd</a><br/>";

}}

echo "Page: $page/$poststot<br/>";

echo "<a href=\"index.php?action=newthread&id=$id&nick=$nick&pass=$pass\">New Topic</a>";

echo "<br/><a href=\"index.php?nick=$nick&pass=$pass\">Home</a>";

} else echo "Viewing impossible!<br/><a href=\"index.php?nick=$nick&pass=$pass\">Home</a>";

echo "</p>";

echo "</card>";

}

 

Any help with this woll be much appreciated as its the last error on the script, then it will be 100% working ;-) thanks ;-)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.