PDA

View Full Version : per page???


GeorgeofCS
10-23-2002, 08:26 PM
Ok I'm attempting to alter a pice of code I rewrote for other purposes. The only problem is that I need the script to show say 10 per page. Can anyone help?

Here's the bit of code.

if ($action=="") {
include("./global.php");
//check usergroup of user to see if they can use Profile
if ($bbuserinfo[userid]==0) {
show_nopermission();
}

$sponsors=$DB_site->query("SELECT id,name,sponban,sponlink,sponpoint,sponexp,sponhit s FROM sponsors WHERE (sponexp<=sponhits OR sponhits=0) ORDER BY id DESC");
$c = 0;
while ($sponsor=$DB_site->fetch_array($sponsors)) {

$sponsorbody .= "<br><a href=\"sponsor.php?s=$session[sessionhash]&action=sponsee&sponid=$sponsor[id]\" target=\"_blank\"><img src=\"$sponsor[sponban]\" border=\"0\"></a><br>Visiting $sponsor[name] is worth $sponsor[sponpoint] points.<br>";
$c = $c + 1;
}

if ($c==0) {
$sponsorbody .= "No Sponsors found";
}

$sponsorbody .= "";
eval("dooutput(\"".gettemplate("sponsor_main")."\");");
}

Velocd
10-25-2002, 05:53 PM
You will need to replace this:


$sponsors=$DB_site->query("SELECT id,name,sponban,sponlink,sponpoint,sponexp,sponhit s FROM sponsors WHERE (sponexp<=sponhits OR sponhits=0) ORDER BY id DESC");

With this:


$sponsors=$DB_site->query("SELECT id,name,sponban,sponlink,sponpoint,sponexp,sponhit s FROM sponsors WHERE (sponexp<=sponhits OR sponhits=0) LIMIT 10 ORDER BY id DESC");


Adding the LIMIT 10 attribute specifies how many sponsers should be grabbed per page. You will need to do some more coding though to implement pages, etc.