| DJ Hands3 |
11-22-2010 12:35 AM |
add a simple pagination to mysql results
1) Project Details: (as title - just limit results to 10 per page also must have next / previous and page numbers displayed)
2) Payment Amount: TBC - please quote me
3) Payment method/ details (Paypal):
4) Additional Info (see code below):
PHP Code:
<?php
// Error reporting: error_reporting(E_ALL^E_NOTICE);
// Including the DB connection file: require 'connect.php';
$extension=''; $files_array = array();
/* Opening the thumbnail directory and looping through all the thumbs: */
$dir_handle = @opendir($directory) or die("There is an error with your file directory!");
while ($file = readdir($dir_handle)) { /* Skipping the system files: */ if($file{0}=='.') continue; /* end() returns the last element of the array generated by the explode() function: */ $extension = strtolower(end(explode('.',$file))); /* Skipping the php files: */ if($extension == 'php') continue;
$files_array[]=$file; }
/* Sorting the files alphabetically */ sort($files_array,SORT_STRING);
# intialize a new array of files that we want to show $file_downloads=array();
# add a file to the $goodfiles array if its name doesn't begin with a period foreach($files_array as $f){ if(strpos($f,'.')!==0){ array_push($file_downloads,$f); } }
$file_downloads=array();
$result = mysql_query("SELECT * FROM download_manager");
if(mysql_num_rows($result)) while($row=mysql_fetch_assoc($result)) { /* The key of the $file_downloads array will be the name of the file, and will contain the number of downloads: */ $pages = array_chunk($file_downloads, 5); $file_downloads[$row['filename']]=$row['downloads']; }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>www.djhandsfree.co.uk - Podcast area - lock into DJ Handsfree Saturdays 4-6pm live on www.flexfm.co.uk and London on 99.7FM</title>
<style type="text/css">
body{ margin:0; padding:0; line-height: 1.5em; }
b{font-size: 110%;} em{color: red;}
#maincontainer{ width: 1400px; /*Width of main container*/ margin: 0 auto; /*Center container on page*/ }
#topsection{ height: 180px; /*Height of top section*/ }
#topsection h1{ margin: 0; padding-top: 15px; }
#contentwrapper{ float: left; width: 100%; }
#contentcolumn{ margin-left: 200px; /*Set left margin to LeftColumnWidth*/ }
#leftcolumn{ float: left; width: 200px; /*Width of left column*/ margin-left: -1400px; /*Set left margin to -(MainContainerWidth)*/
}
#footer{ clear: left; width: 100%; background: black; color: #FFF; text-align: center; padding: 4px 0; }
#footer a{ color: #FFFF80; }
.innertube{ margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/ margin-top: 0; }
</style>
<link rel="stylesheet" type="text/css" href="styles.css" /> <style type="text/css" media="screen"> @import "general.css"; /* Mostly just text styling. */
#Content { text-align:center; /* Hack for IE5/Win */ width:800px; margin:0px auto; /* Right and left margin widths set to "auto" */
padding:15px; border:1px dashed #333; background-color:#fff; } </style>
<style type="text/css">
/*Credits: Dynamic Drive CSS Library */ /*URL: http://www.dynamicdrive.com/style/ */<!-- Hide entire CSS code from IE6 --> <![if !IE 6]>
.shiftcontainer{ position: relative; left: 7px; /*Number should match -left shadow depth below*/ top: 7px; /*Number should match -top shadow depth below*/ }
.shadowcontainer{ width: 800px; /* container width*/ background: transparent url(img/bigshadow.gif) no-repeat bottom right; }
.shadowcontainer .innerdiv{ /* Add container height here if desired */ background-color: white; border: 1px solid gray; padding: 6px; position: relative; left: -7px; /*shadow depth*/ top: -7px; /*shadow depth*/ }
</style>
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.2.6.css" media="screen" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="script.js"></script>
</head>
<body> <div id="maincontainer">
<div id="topsection"><div class="innertube"><img border="0" src="img/logo.jpg" width="1022" height="113"><br>DJ Handsfree Podcasts - LOCK INTO DJHANDSFREE SATURDAYS 4-6PM LIVE ON FLEXFM.CO.UK AND 99.7 FM LONDON</div></div>
<div id="contentwrapper"> <div id="contentcolumn"> <div class="innertube">
<div id="Content"> <p align="center"> <a href="http://www.flexfm.co.uk" target="_blank"> <img border="0" src="img/carbonpirate324x243.jpg" width="324" height="243" align="middle"></a></p><br>
<?php
foreach($files_array as $key=>$val) { echo '<div class="shiftcontainer"> <div class="shadowcontainer"> <div class="innerdiv"> <b><a href="download.php?file='.urlencode($val).'">'.$val.'</a> </b> <br /> This file has been downloaded - '.(int)$file_downloads[$val].' time(s)<br /><br /> <a href="download.php?file='.urlencode($val).'" title="Download file '.$val.'"><img border="0" src="img/downloads.png" width="48" height="48" align="middle"></a> </div> </div> </div> <br /><br />
<div class="shiftcontainer2"> <div class="shadowcontainer2"> </div> </div>' ; } ?> <img border="0" src="img/flyers/untold-sounds-nov2010.jpg" width="507" height="720"> </div>
</div> </div> </div>
<div id="leftcolumn"> <div class="innertube"><?php include("guest.php"); ?></div></div> </div>
</body> </html>
|