Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
DaveTomneyUK
Hangin' Around


Joined: Sep 27, 2003
Posts: 49

PostPosted: Sun Aug 14, 2005 11:11 am Reply with quote

Could someone modify this code so it allows pages.

EG - page 1 shows 1-14 and page 2 shows 15-30 etc.

Code:


<?php
   require_once('header.php');

function main() {
   $total = "18";
   $result = mysql_num_rows(mysql_query("SELECT * FROM my_gallery WHERE active='1'"));

if ($result > 1) {
   $result = $result-1;
   mt_srand((double)microtime()*1000000);
   $bannum = mt_rand(0, $result);
} else {
   $bannum = 0;
}
   $result2 = mysql_query("SELECT id, hits, name, imageurl, clickurl, format, date, size FROM my_gallery WHERE active='1' LIMIT $total");
$a = 0;

   //echo "<table width=\"90%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
   //echo "<td><div align=\"center\" class=\"cattitle\">"._GALLERY_HEADTITLE."</div></td></table><br>\n";

   echo "<table width=\"90%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
   echo "<td align=\"center\" width=\"100%\"><div align=\"center\" class=\"cat\"><font class=\"cattitle\">"._GALLERY_ANIMATION."</div></td></table>\n";

   echo "<table width=\"90%\" cellpadding=\"2\" cellspacing=\"5\" border=\"0\" align=\"center\">\n";

   while ($row = mysql_fetch_array($result2)) {

if ($a == 0) {
   echo "<tr>";
}
   echo "<td align=\"center\" width=\"50%\" class=\"row1\" valign=\"center\">";

   echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">";
   echo "<td align=\"center\" width=\"25%\" class=\"row3\" valign=\"center\">";

   $id = intval($row['id']);
   $hits = intval($row['hits']);
   $name = $row[name];
   $imageurl = $row[imageurl];
   $clickurl = $row[clickurl];
   $format = $row[format];
   $date = $row[date];
   $size = intval($row['size']);

   echo "<a href=\"gallery.php?cat=animations&amp;id=$id\"><img src=\"$imageurl\" width=\"75\" height=\"75\" border=\"0\"></a></td>\n";

   echo "<td align=\"center\" width=\"40%\" class=\"row1\" valign=\"center\"><font class=\"forumlink\"><b>"._GALLERY_NAME." :</b> $name";
   echo "<br><b>"._GALLERY_ADDED."</b>: $date";
    echo "<br><b>"._GALLERY_HITS."</b>: $hits";
    //echo "<br><b>"._GALLERY_FORMAT."</b>: $format";
    //echo "<br><b>"._GALLERY_SIZE."</b>: $size";

    echo "</td>";
    $a++;
    if($a == 2) { echo "</tr>"; $a = 0; }

    echo "</table>";
  }
  if($a ==1) { echo "<td width='50%'>&nbsp;</td></tr></table>"; } else { echo "</tr></table>"; }

}

function update($id) {
   $id = intval($id);
   $row = mysql_fetch_array(mysql_query("SELECT clickurl FROM my_gallery WHERE id='$id'"));
   $clickurl = $row['clickurl'];
   mysql_query("UPDATE my_gallery SET hits=hits+1 WHERE id='$id'");
   header("location: $clickurl");
   //require_once('$clickurl');
}

if (isset($id)) {
   update($id);
} else {
   main();
}
   require_once('footer.php');
?>

_________________
Image
Only registered users can see links on this board! Get registered or login! - Only registered users can see links on this board! Get registered or login! - Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©