Retrouvez les publications relatives à ces discussions dans
nos rubriques PHP, SQL.
liste des forums
liste des discussions
Participer à la discussion
-
Message publié le jeudi 11 février 2010 - 09h33 par icadop.
-
Bonjour,
Voilà, j'ai réalisé une page... et j'y ai mis une pagianation "précedent...123456... suivant!
Sur cette page j'ai bien des cases à cocher et qd je clique sur sélection, il me prend bien uniquement les cases cochées de cette pages mais lorsque je fais suivant il a tout perdu
voici le code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<title>Untitled Document</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/pg.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form method="get" action="res_sel.php">
<?php
// Haut Page
require "haut.php";
require "pagin.php";
// Connection
require "connect.php";
mysql_select_db("icadop_be");
// Déclaration des variables
$where='';
// Construction du where
if (isset($_GET['c1']) AND isset($_GET['c2']) AND isset($_GET['c3']) AND isset($_GET['c4'])
AND isset($_GET['c5']) AND isset($_GET['c6']) AND isset($_GET['c7']) AND isset($_GET['c8']))
{
if ($_GET['c1']<>"" AND $_GET['c2']<>'Tous')
{
$where="WHERE $_GET[c2] LIKE '%$_GET[c1]%' ";
}
if ($_GET['c4']<>"" AND $_GET['c5']<>'tous')
{
$where.="$_GET[c3] $_GET[c5] LIKE '%$_GET[c4]%' ";
}
if ($_GET['c7']<>"" AND $_GET['c8']<>'tous')
{
$where.="$_GET[c6] $_GET[c8] LIKE '%$_GET[c7]%' ";
}
//
if ($_GET['c1']<>"" AND $_GET['c2']=='Tous les champs')
{
echo "WHERE1";
}
if ($_GET['c4'] <>"" AND $_GET['c5']=='Tous les champs')
{
echo "dommage2";
}
if ($_GET['c7']<>"" AND $_GET['c8']=='Tous les champs')
{
echo "dommage3";
}
}
// Recherche du nombre de lignes
$sql="SELECT count(*) AS nb_total FROM t_bib ";
$sql.=$where;
$nb_total=mysql_query($sql);
$nb_total=mysql_fetch_array($nb_total);
$nb_total=$nb_total['nb_total'];
echo $nb_total;
if ($nb_total==0)
{
echo "<table width='100%' border='0'>";
echo "<tr>";
echo "<td><div align='center' class='t-titre'>Aucune réponse trouvée !!</div></td>";
echo "</tr>";
echo "</table>";
}
else
{
echo "<table width='100%' border='0'>";
echo "<tr>";
echo "<td><div align='center' class='t-titre'>Résultat de votre recherche :</div></td>";
echo "</tr>";
echo "</table>";
// Numero de page, 1 par défaut
if (isset($_GET['page']) && is_numeric($_GET['page']))
$page=$_GET['page'];
else
$page=1;
// $pagination
$pagination=10;
// Numéro du 1er enregistrement a lire
$limit_start = ($page-1) * $pagination;
//Préparation de la requete
$sql="SELECT * FROM t_bib ".$where."LIMIT $limit_start,$pagination";
echo $sql;
$resultat=mysql_query($sql);
$total=mysql_num_rows($resultat);
// pagination
$nb_pages=ceil($nb_total/$pagination);
//echo "<br />";
echo "<table align='center' border='0' width='90%' class='t12'>";
echo "<tr>";
echo "<td>Le total est.$total</td>";
echo "<td><div align='right'><input type='submit' name='sélection' value='Votre Sélection...'></div><br></td>";
echo "<input type='hidden' name='c1' value='mp'>";
echo "</table>";
echo "<table align='center' border='0' width='95%' class='tab_12'>";
echo "</tr>";
echo "<tr bgcolor=#edf7f2>";
echo "<th width='2%'> </th>";
echo "<th width='15%' class='th_12'> Cote de <br> rangement </th>";
echo "<th width='20%' class='th_12'>Auteur</th>";
echo "<th width='48%' class='th_12'>Titre</th>";
echo "<th width='5%' class='th_12'>Diponibilité</th>";
echo "<th width='5%' class='th_12'>Détail</th>";
echo "</tr>";
while ($enr=mysql_fetch_array($resultat))
{
echo "<tr>";
echo "<td class='td_12'><input type='checkbox' name='selection[]' value='".$enr['id_fm']."'></td>";
echo "<td class='td_12'>";
echo ($enr['cote_cdu_calculee']);
echo "</td>";
echo "<td class='td_12'>";
echo ($enr['auteur']);
echo "</td>";
echo "<td class='td_12'>";
echo ($enr['titre']);
echo "</td>";
echo "<td align='center' class='td_12'>";
if ($enr['commentaire_emprunt']=='Disponible')
{
echo "<img src='images/ok.gif' width='66' height='21' border='0' alt='Disponible'>";
}
else
{
echo "<img src='images/notok.gif' width='66' height='21' border='0' alt='Non disponible'>";
}
echo "</td>";
// champs pour détail
$titre=urlencode(htmlspecialchars($enr['titre']));
$edition=urlencode(htmlspecialchars($enr['edition_lieu'].' : '.$enr['edition_editeur'].', '
.$enr['edition_date']));
if ($enr['collation_illustration']<>'')
{
$collation=urlencode(htmlspecialchars($enr['collation_page'].' : '.$enr['collation_illustration'].' ; '
.$enr['collation_taille']));
}
else
{
$collation=urlencode(htmlspecialchars($enr['collation_page'].' ; '.$enr['collation_taille']));
}
$collection=urlencode(htmlspecialchars($enr['collection_titre']));
echo "<td align='center'>";
echo "<a href='detail.php?titre=$titre&edition=$edition&collation=$collation&collection=$collection'><img src='images/info.jpg' width='16' height='16' border='0' alt='Détail'></a>";
echo "</td>";
echo "</tr>";
}
;
echo "</table>";
echo "<br>";
// Affichage pagination
$a= '<p class="pagination">'.pagination($page,$nb_pages).'</p>';
echo "<table align='center' border='0 width='90%' class='t12'>";
echo "<tr>";
echo "<td align='center'>$a</td>";
echo "</table>";
}
?>
</form>
</body>
</html>
code pagin.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<title>Document sans titre</title>
</head>
<body>
<?php
function pagination($current_page, $nb_pages, $link='?page=%d&re=10', $around=5, $firstlast=1)
{
$pagination = '';
if ( !preg_match('/%d/', $link) ) $link .= '%d';
if ( $nb_pages > 1 ) {
// Lien précédent
if ( $current_page > 1 )
$pagination .= '<a class="prevnext" href="'.sprintf($link, $current_page-1).'" title="Page précédente">« Précédent</a>';
else
$pagination .= '<span class="prevnext disabled">« Précédent</span>';
// Lien(s) début
for ( $i=1 ; $i<=$firstlast ; $i++ ) {
$pagination .= ' ';
$pagination .= ($current_page==$i) ? '<span class="current">'.$i.'</span>' : '<a href="'.sprintf($link, $i).'">'.$i.'</a>';
}
// ... apres pages début ?
if ( ($current_page-$around) > $firstlast+1 )
$pagination .= ' …';
// On boucle autour de la page courante
$start = ($current_page-$around)>$firstlast ? $current_page-$around : $firstlast+1;
$end = ($current_page+$around)<=($nb_pages-$firstlast) ? $current_page+$around : $nb_pages-$firstlast;
for ( $i=$start ; $i<=$end ; $i++ ) {
$pagination .= ' ';
if ( $i==$current_page )
$pagination .= '<span class="current">'.$i.'</span>';
else
$pagination .= '<a href="'.sprintf($link, $i).'">'.$i.'</a>';
}
// ... avant page nb_pages ?
if ( ($current_page+$around) < $nb_pages-$firstlast )
$pagination .= ' …';
// Lien(s) fin
$start = $nb_pages-$firstlast+1;
if( $start <= $firstlast ) $start = $firstlast+1;
for ( $i=$start ; $i<=$nb_pages ; $i++ ) {
$pagination .= ' ';
$pagination .= ($current_page==$i) ? '<span class="current">'.$i.'</span>' : '<a href="'.sprintf($link, $i).'">'.$i.'</a>';
}
// Lien suivant
if ( $current_page < $nb_pages )
$pagination .= ' <a class="prevnext" href="'.sprintf($link, ($current_page+1)).'" title="Page suivante">Suivant »</a>';
else
$pagination .= ' <span class="prevnext disabled">Suivant »</span>';
}
return $pagination;
}
?>
</body>
</html>
-
Message publié le mardi 09 mars 2010 - 11h31 par telnes. toujours revenir au debut - http://telnesmaster.free.fr/allhtml/index2.html - http://telnesmaster.free.fr/litetemplate - http://www.hotcontest.org
-
hello
c'est normal dans un cas tu soumet ton form et dans l'autre non !
liste des forums
liste des discussions
Participer à la discussion
Vous devez obligatoirement vous identifier en tant que membre pour participer à cette discussion.