Accueil > > > SYSTÈME DE PAGINATION AVEC BDD ET IMAGES (FICHIERS)
SYSTÈME DE PAGINATION AVEC BDD ET IMAGES (FICHIERS)
Information sur la source
Description
Azul à tous, Dans ce petit programme, j'ai implémenté un système de pagination sur des données que je lis à partir d'une table et dont des fichiers correspondants se trouvent dans un dossier (des images, dans mon cas) Je poste ce script surtout pour avoir des suggestion à l'améliorer. Il fonctionne parfaitement
Source
- <?php
- require_once('include/header.inc.php');
- require_once('include/leftMenu.inc.php');
- require_once('Cfg/config.inc.php');
- ?>
- <div class="rightContent">
- <?php
- $tal=$_GET['ta2'];
- $tenq=$_GET['tenq'];
- /*it is the page concerned by this show*/
- $pagen="lister.php";
- $start=$_GET['start'];
- if(strlen($start)>0&&!is_numeric($start)){
- echo'Erreur dans le paramètre passée';;
- exit();/*i go out from this page*/
- }
- $eu = ($start - 0);
- $limit = 2;
- $this1 = $eu + $limit;
- $back = $eu - $limit;
- $next = $eu + $limit;
- //i will fetch for the number of records in my table
- $query2="SELECT*FROM $tenq";
- // so as to help me to break the page
- $result2=mysql_query($query2)or die('Impossible to perform the SELECTION query 1<br/>'.mysql_error());
- $nume=mysql_num_rows($result2);
- /* Thus we have just stored the number of rows that exist in our table */
- /* now i will print the table headers in which i will save the elemens of my table*/
- $bgcolor="#f1f1f1";
- echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0 class=mytableinlister>";
- $query=" SELECT * FROM $tenq limit $eu, $limit ";
- $result=mysql_query($query)or die('Impossible to perform the SELECTION query 2<br/>'.mysql_error());
- /* now i will display my stupid data within this table i just started drawing */
- while($broughtdata = mysql_fetch_array($result))
- {
- if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
- else{$bgcolor='#f1f1f1';}
- echo "<tr >";
- echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$broughtdata[ufn]</font></td>";
- echo'</tr>';
- echo'<tr>';
- echo'<td align="center">';
- $sfn=$broughtdata['sfn'];
- $wherearemyimages="admin/Images";
- $openmywami=opendir($wherearemyimages);
- while($myfilelookedfor=readdir($openmywami)){
- $thelinktomf=$wherearemyimages.'/'.$myfilelookedfor;
- if(file_exists($thelinktomf)&&$broughtdata['sfn']==$myfilelookedfor){
- echo"<a href=\"productsdetails.php?idImg=$idphoto#portsdetailslabel\"><img src=\"".$thelinktomf."\" width=\"150\" height=\"150\" border=\"0\"/></a></td>";
- }
- }
- echo'</td>';
- echo'</tr>';
- }
- echo "</table>";
- /*i have just ended displaying my data in this table */
- if($nume > $limit ){
- /*i will display links under this table if sufficient records are there to page */
- /* thus the links to show are the previous and next links with page numbers*/
- echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
- /*if the variable $back is equal to 0 or more then only we will display the link Previous so as
- * to move back within my table */
- if($back >=0) {
- print "<a href='$page_name?start=$back&tenq=$tenq'><img src=\"images/previous.jpeg\" border=\"0\"></a>";
- }
- /* here again, i display my links at the center,
- * but i must avoid displaying the current page as a link*/
- echo "</td><td align=center width='30%'>";
- $i=0;
- $l=1;
- for($i=0;$i < $nume;$i=$i+$limit){
- if($i <> $eu){
- echo " <a href='$page_name?start=$i&tenq=$tenq'><font face='Verdana' size='2'>$l</font></a> ";
- }
- else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red
- $l=$l+1;
- }
- echo "</td><td align='right' width='30%'>";
- /*if this is nopt the last page then we can display the following link
- * I verify this here */
- if($this1 < $nume) {
- print "<a href='$page_name?start=$next&tenq=$tenq'><img src=\"images/next.jpeg\" border=\"0\"></a>";}
- echo "</td></tr></table>";
-
- }// end of if verifying sufficient records are there to display bottom navigational link.
- ?>
-
- </div>
- <?php
- require_once('include/footer.inc.php');
- ?>
<?php
require_once('include/header.inc.php');
require_once('include/leftMenu.inc.php');
require_once('Cfg/config.inc.php');
?>
<div class="rightContent">
<?php
$tal=$_GET['ta2'];
$tenq=$_GET['tenq'];
/*it is the page concerned by this show*/
$pagen="lister.php";
$start=$_GET['start'];
if(strlen($start)>0&&!is_numeric($start)){
echo'Erreur dans le paramètre passée';;
exit();/*i go out from this page*/
}
$eu = ($start - 0);
$limit = 2;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
//i will fetch for the number of records in my table
$query2="SELECT*FROM $tenq";
// so as to help me to break the page
$result2=mysql_query($query2)or die('Impossible to perform the SELECTION query 1<br/>'.mysql_error());
$nume=mysql_num_rows($result2);
/* Thus we have just stored the number of rows that exist in our table */
/* now i will print the table headers in which i will save the elemens of my table*/
$bgcolor="#f1f1f1";
echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0 class=mytableinlister>";
$query=" SELECT * FROM $tenq limit $eu, $limit ";
$result=mysql_query($query)or die('Impossible to perform the SELECTION query 2<br/>'.mysql_error());
/* now i will display my stupid data within this table i just started drawing */
while($broughtdata = mysql_fetch_array($result))
{
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
else{$bgcolor='#f1f1f1';}
echo "<tr >";
echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>$broughtdata[ufn]</font></td>";
echo'</tr>';
echo'<tr>';
echo'<td align="center">';
$sfn=$broughtdata['sfn'];
$wherearemyimages="admin/Images";
$openmywami=opendir($wherearemyimages);
while($myfilelookedfor=readdir($openmywami)){
$thelinktomf=$wherearemyimages.'/'.$myfilelookedfor;
if(file_exists($thelinktomf)&&$broughtdata['sfn']==$myfilelookedfor){
echo"<a href=\"productsdetails.php?idImg=$idphoto#portsdetailslabel\"><img src=\"".$thelinktomf."\" width=\"150\" height=\"150\" border=\"0\"/></a></td>";
}
}
echo'</td>';
echo'</tr>';
}
echo "</table>";
/*i have just ended displaying my data in this table */
if($nume > $limit ){
/*i will display links under this table if sufficient records are there to page */
/* thus the links to show are the previous and next links with page numbers*/
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
/*if the variable $back is equal to 0 or more then only we will display the link Previous so as
* to move back within my table */
if($back >=0) {
print "<a href='$page_name?start=$back&tenq=$tenq'><img src=\"images/previous.jpeg\" border=\"0\"></a>";
}
/* here again, i display my links at the center,
* but i must avoid displaying the current page as a link*/
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i&tenq=$tenq'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red
$l=$l+1;
}
echo "</td><td align='right' width='30%'>";
/*if this is nopt the last page then we can display the following link
* I verify this here */
if($this1 < $nume) {
print "<a href='$page_name?start=$next&tenq=$tenq'><img src=\"images/next.jpeg\" border=\"0\"></a>";}
echo "</td></tr></table>";
}// end of if verifying sufficient records are there to display bottom navigational link.
?>
</div>
<?php
require_once('include/footer.inc.php');
?>
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Php & MySql ??? [ par nova85 ]
Je voudrai savoir si il est possible de realiser un site assez important juste avec une BDD mysql , si c'est capable de resister , et surtout savoir s
image php Mysql [ par arnaldo21 ]
bonjour pourriez-vous me donner un exemple concret d'affichage d'image a partir d'une bdd. J'utilise un upload qui stock le nom de l'image dans la bdd
php/mysql et album photo sécurisé [ par pumbaa ]
Salut!! J’ai crée un album d’image avec php/MySQL. Les images ce trouvent
Php - MySql + Images [ par 68_abis ]
Bonjour à tous,Peut-être cette question à e-t-elle été déjà posée, mais je n'en ai pas trouvée de traces,
multiple upload a mysql avec php [ par Xavihb ]
Salut,J'aurais besoin de savoir comment faire un multiple upload d'images à une base de données mySQL à l'aide de PHP. Les champs des i
bdd+php avec easyphp [ par neosqual ]
Bonjour a tous, J'aurai voulu savoir si il y a qq chose de spécial à faire pour accéder à une bdd (créée en mysql sous e
Help !!! probleme de connection BDD et affichage dans une pasge php [ par chapata ]
Bonjour a tous,J'ai installer EasyPHP en début de semaine et je me suis mit depuis peu aux BDD (mysql et php), et j'ai une question pour vou
formulaire Modifier BDD Mysql [ par ombrey20 ]
j suis debutant en php,j'ai deja creer un formulaire ajout d'enregistrement dans une BDD Mysql via php.. et j veux faire un autre pour la modification
récupérer une valeur [ID] extraite de la bdd pour obtenir les infos [ par dieusurterre ]
Je n'arrive pas à trouver comment faire pour que ma page ../fiche.php?ID=[valeur bdd] affiche les renseignement du rows de la bdd relatif à
clic sur un tableau d'images lues à partie de mysql/php [ par amewole ]
Voici mon problème : Je suis debutant php j'extrais des données images d' une table mysql et je mets ces données images dans un tableau
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|