par
karenma » 16 janv. 2008, 17:17
bonjour
voilà je voudrais afficher les résultats de ma requete page par page j'ai trouvé un tuto qui parlé de ça et j'ai essayé de l'appliquer à mon cas Mais le problème c que j'ai les numéros de page qui s'affichent 1,2,3 et c bien des liens mais qui renvoient vers des pages vides
Pourtant j'ai bien des réponses à la page 1
Mais rien à la page 2 alors qu'il devrait y en avoir
Je ne comprends pas merci d'avande pour votre aide
Voici le code de ma 1ère page
<html >
<head>
<title>Document sans titre</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:62px;
top:130px;
width:627px;
height:266px;
z-index:1;
}
#Layer2 {
position:absolute;
left:70px;
top:36px;
width:828px;
height:290px;
z-index:1;
}
-->
</style>
</head>
<body>
<div id="Layer2">
<form id="form1" name="form1" method="post" action="integrationmotcleetlienpage.php">
<table width="527" height="160" border="0" cellpadding="0">
<tr>
<td width="144"><input name="mot" type="text" id="mot"></td>
<td width="186"><div align="center">
<div align="right">
<select name="quoi" id="quoi">
<option value="avion">marre</option>
<option value="voiture">voiture</option>
</select>
</div>
</div></td>
<td width="189"><div align="center">
<select name="endroit" id="endroit">
<option>touslesdépartements</option>
<option value="13009">13009</option>
</select>
</div></td>
</tr>
<tr>
<td height="58" colspan="3"><div align="center">
<input type="submit" name="Submit" value="rechercher" />
</div></td>
</tr>
</table>
</form>
</div>
</body>
</html>
et le code de ma 2ème page integrationmotcleetlienpage.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-1" />
<title>Document sans titre</title>
</head>
<body>
<?php
$liendb = mysql_connect("nomserveur","user","pass");
mysql_select_db ("nombase");
function protection(&$value) {
$value = (get_magic_quotes_gpc())? mysql_real_escape_string(stripslashes(trim($value))) : mysql_real_escape_string(trim($value));
return $value;
}
$quoi = !empty($_POST['quoi'])? protection($_POST['quoi']) : '';
$endroit = !empty($_POST['endroit'])? protection($_POST['endroit']) : '';
$sql= "SELECT texte,titre,id FROM annonce WHERE categorie = '" . $quoi . "' AND departement = '" . $endroit . "'";
if (empty($_POST['mot']) === FALSE) {
$tab = explode(' ', $_POST['mot']);
array_walk($tab, 'protection');
$IN = implode("','", $tab);
$sql .= " AND motcle1 IN ('$IN')";
}
$resultat_sql = mysql_query($sql) or die (mysql_error());
$nombreDeMessagesParPage = 2;
$n =mysql_num_rows($resultat_sql);
$nombresDePages =ceil($n/$nombreDeMessagesParPage );
echo 'Page : ';
for ($i = 1 ; $i <= $nombresDePages ; $i++)
{
echo '<a href="integrationmotcleetlienpage.php?page=' . $i . '">' . $i . '</a> ';
}
if (isset($_GET['page']))
{
$page = $_GET['page']; }
else
{
$page = 1; }
$premierMessageAafficher = ($page - 1) * $nombreDeMessagesParPage;
$sqll= "SELECT texte,titre,id FROM annonce WHERE categorie = '" . $quoi . "' AND departement = '" . $endroit . "' ORDER BY id DESC LIMIT " . $premierMessageAafficher . ", " . $nombreDeMessagesParPage;
if (empty($_POST['mot']) === FALSE) {
$tab = explode(' ', $_POST['mot']);
array_walk($tab, 'protection');
$IN = implode("','", $tab);
$sqll .= " AND motcle1 IN ('$IN')";
}
$resultatt_sql = mysql_query($sqll) or die (mysql_error());
?>
<!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=iso-8859-1" />
<title>Document sans nom</title>
</head>
<body>
<table style="border:1px solid black; width:100%">
<?php while ($resultat = mysql_fetch_assoc($resultatt_sql))
{ ?>
<tr>
<td><a href="description50page.php?<?php echo 'id='.intval($resultat['id']) ?>"><?php echo htmlentities($resultat['titre'])?></a></td>
</tr>
<?php } mysql_free_result($resultatt_sql);
mysql_close($liendb);
?>
</table>
</body>
</html>
bonjour
voilà je voudrais afficher les résultats de ma requete page par page j'ai trouvé un tuto qui parlé de ça et j'ai essayé de l'appliquer à mon cas Mais le problème c que j'ai les numéros de page qui s'affichent 1,2,3 et c bien des liens mais qui renvoient vers des pages vides
Pourtant j'ai bien des réponses à la page 1
Mais rien à la page 2 alors qu'il devrait y en avoir
Je ne comprends pas merci d'avande pour votre aide
Voici le code de ma 1ère page
[php]
<html >
<head>
<title>Document sans titre</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:62px;
top:130px;
width:627px;
height:266px;
z-index:1;
}
#Layer2 {
position:absolute;
left:70px;
top:36px;
width:828px;
height:290px;
z-index:1;
}
-->
</style>
</head>
<body>
<div id="Layer2">
<form id="form1" name="form1" method="post" action="integrationmotcleetlienpage.php">
<table width="527" height="160" border="0" cellpadding="0">
<tr>
<td width="144"><input name="mot" type="text" id="mot"></td>
<td width="186"><div align="center">
<div align="right">
<select name="quoi" id="quoi">
<option value="avion">marre</option>
<option value="voiture">voiture</option>
</select>
</div>
</div></td>
<td width="189"><div align="center">
<select name="endroit" id="endroit">
<option>touslesdépartements</option>
<option value="13009">13009</option>
</select>
</div></td>
</tr>
<tr>
<td height="58" colspan="3"><div align="center">
<input type="submit" name="Submit" value="rechercher" />
</div></td>
</tr>
</table>
</form>
</div>
</body>
</html>
[/php]
et le code de ma 2ème page integrationmotcleetlienpage.php:
[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-1" />
<title>Document sans titre</title>
</head>
<body>
<?php
$liendb = mysql_connect("nomserveur","user","pass");
mysql_select_db ("nombase");
function protection(&$value) {
$value = (get_magic_quotes_gpc())? mysql_real_escape_string(stripslashes(trim($value))) : mysql_real_escape_string(trim($value));
return $value;
}
$quoi = !empty($_POST['quoi'])? protection($_POST['quoi']) : '';
$endroit = !empty($_POST['endroit'])? protection($_POST['endroit']) : '';
$sql= "SELECT texte,titre,id FROM annonce WHERE categorie = '" . $quoi . "' AND departement = '" . $endroit . "'";
if (empty($_POST['mot']) === FALSE) {
$tab = explode(' ', $_POST['mot']);
array_walk($tab, 'protection');
$IN = implode("','", $tab);
$sql .= " AND motcle1 IN ('$IN')";
}
$resultat_sql = mysql_query($sql) or die (mysql_error());
$nombreDeMessagesParPage = 2;
$n =mysql_num_rows($resultat_sql);
$nombresDePages =ceil($n/$nombreDeMessagesParPage );
echo 'Page : ';
for ($i = 1 ; $i <= $nombresDePages ; $i++)
{
echo '<a href="integrationmotcleetlienpage.php?page=' . $i . '">' . $i . '</a> ';
}
if (isset($_GET['page']))
{
$page = $_GET['page']; }
else
{
$page = 1; }
$premierMessageAafficher = ($page - 1) * $nombreDeMessagesParPage;
$sqll= "SELECT texte,titre,id FROM annonce WHERE categorie = '" . $quoi . "' AND departement = '" . $endroit . "' ORDER BY id DESC LIMIT " . $premierMessageAafficher . ", " . $nombreDeMessagesParPage;
if (empty($_POST['mot']) === FALSE) {
$tab = explode(' ', $_POST['mot']);
array_walk($tab, 'protection');
$IN = implode("','", $tab);
$sqll .= " AND motcle1 IN ('$IN')";
}
$resultatt_sql = mysql_query($sqll) or die (mysql_error());
?>
<!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=iso-8859-1" />
<title>Document sans nom</title>
</head>
<body>
<table style="border:1px solid black; width:100%">
<?php while ($resultat = mysql_fetch_assoc($resultatt_sql))
{ ?>
<tr>
<td><a href="description50page.php?<?php echo 'id='.intval($resultat['id']) ?>"><?php echo htmlentities($resultat['titre'])?></a></td>
</tr>
<?php } mysql_free_result($resultatt_sql);
mysql_close($liendb);
?>
</table>
</body>
</html> [/php]