Jump to content


A question that's so painfully easy you'll hate me for asking


6 replies to this topic

#1 Mac

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 12 March 2006 - 02:28 PM

Sorry, I know you guys must be sick of this question, but I can't help it. I'm trying to add PHP Pagination to the script I posted below. I've tried most of the tutorials here, but I just can't convert them over to my site. I'm not exactly a beginner at this, but I'm far from being an expert. If someone could help me with this, I'd be really thankful. I'm afraid I need baby steps though. It's the only way I can learn how to do this once and for all.

Here's my script so far:


<?php mysql_connect("localhost","####","####"); mysql_select_db("socomcen_home"); {
$result = mysql_query("select * from templates where validate like '%1%' order by id");
while($r=mysql_fetch_array($result)){ 
$id=$r["id"];
$name=$r["name"];
$game=$r["game"];
$screenshot=$r["screenshot"];
$designer=$r["designer"];
$designerlink=$r["designerlink"];
$preview=$r["preview"];
$download=$r["download"];
echo "
<!-- Start Templates Repeat -->
<div style=\"float: left; height: 118px; width: 369px;\">
<div class=\"templates-preview\"><img src=\"screens/$screenshot\" alt=\"\" /></div>
<div class=\"templates-info\">
<div class=\"templates-info2\"><span style=\"font-size: 10px; color: #757575;\">Designed by</span> <a href=\"../forums/$designerlink\">$designer</a></div>
<div class=\"templates-info2\"><span style=\"font-size: 10px; color: #757575;\">This is a </span>$game <span style=\"font-size: 10px; color: #757575;\">template.</span></div>
<div class=\"templates-info2\"><div style=\"float: left;\"><span style=\"font-size: 10px; color: #757575;\">Template ID Number:</span> <a href=\"link.php?view=$id\" target=\"_blank\">$id</a></div><div style=\"float: right;\"><span style=\"color: #999966; cursor: default;\" title=\"Need to directly link to this template? Click the id#, then copy the URL\">-?-</span>  </div></div>
</div>
<div class=\"templates-links\">
<div style=\"float: left;\"><a href=\"$preview/\"><img src=\"../background/templates/preview.jpg\" alt=\"\" border=\"0\" /></a></div>
<div style=\"float: right;\"><a href=\"$download\"><img src=\"../background/templates/download.jpg\" alt=\"\" border=\"0\" /></a></div>
</div>
</div>
<!-- End Templates Repeat -->\n\n\n";
}
mysql_close();
?>


I need the pages echoed out like this, with 10 results per page.

Fist | Previous | 1 | 2 | 3 | 4 | 5| ..... | Next | Last


I know this is asking a lot, but could someone add this to the script so I can see what you did? I have 12 other scripts like this on my website that I'm going to try to change.


Thank you for your time and effort.

#2 Jaymz

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 4,104 posts

Posted 12 March 2006 - 03:15 PM

http://www.pixel2life.com/tutorials/PHP_Co...1&ss=pagination

There are some good ones in there...

#3 Mac

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 12 March 2006 - 03:19 PM

Yes, I know. Using their examples, I can always get their scripts to work. The trouble is that I can't seem to convert any of the techniques I learn into my script here. Every attempt so far has failed, and I can't figure out why.


Thank you though for the fast reply. I appreciate the help.

Edited by Mac, 12 March 2006 - 03:20 PM.


#4 Jaymz

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 4,104 posts

Posted 12 March 2006 - 03:29 PM

I'll have to leave this to someone more qualified at coding :D

#5 Mac

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 12 March 2006 - 04:28 PM

Thanks. I'm afraid I'm in way over my head this time. I can get the tutorials to work, but I don't even know where to begin changing them.

#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 13 March 2006 - 04:18 PM

Could you possibly post one of your closest attempts and getting the pagination to work, maybe we could help you debug it.

There is also a topic about this already started (http://www.pixel2life.com/forums/index.php...ndpost&p=128630), maybe you can take a look at it and see if anything pops out at you.

Edited by rc69, 13 March 2006 - 04:29 PM.


#7 Mac

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 17 March 2006 - 11:38 PM

Ah! Thank you sir, you've been extremely helpful. That topic you posted was enough for me to figure this out myself. I owe you one! You solved my problem and helped me learn this at the same time.

Thank you!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users