Bonjour à tous,

Je ne suis, mais là vraiment pas, un expert en php et c'est la raison pour laquelle j'écris sur ce forum.

J'ai une page contenant trois formulaire de recherche (un par catégorie, l'autre par secteur d'activité et le troisième par mot clé):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return validateForm()">
<select name="secteur" id="secteur">
<option name="secteur" value="1">1</option>
<option name="secteur" value="2">2</option>
<option name="secteur" value="3">3</option>
</select>
<input name="" type="submit" />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return validateForm()">
<select name="categorie" id="categorie">
<option name="categorie" value="1">1</option>
<option name="categorie" value="2">2</option>
<option name="categorie" value="3">3</option>
</select>
<input name="" type="submit" /><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return validateForm()">
<input name="mot" type="text" />
<input name="" type="submit" />
</form>
Et j'affiche mes résultats depuis un query avec une pagination:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php include('config.php');
    include ('pagination.php'); //include of paginat page
    $cat = $_POST['categorie'];
    $secteur = $_POST['secteur']; 
	$titre = $_POST['mot']; 
    $per_page = 6; // number of results to show per page
 
if(isset($_POST['mot'])){ 
    $result = mysql_query("SELECT * FROM sqldata where titre like $titre");
}
if(isset($_POST['cat'])){ 
    $result = mysql_query("SELECT * FROM sqldata where cat=$cat");
}
if(isset($_POST['secteur'])){ 
    $result = mysql_query("SELECT * FROM sqldata where secteur=$secteur");
}
 
    $total_results = mysql_num_rows($result);
    $total_pages = ceil($total_results / $per_page);//total pages we going to have
    //-------------if page is setcheck------------------//
    if (isset($_GET['page'])) {
    $show_page = $_GET['page']; //current page
    if ($show_page > 0 && $show_page <= $total_pages) {
    $start = ($show_page - 0) * $per_page;
    $end = $start + $per_page;
    } else {
    // error - show first set of results
    $start = 0;
    $end = $per_page;
    }
    } else {
    // if page isn't set, show first set of results
    $start = 0;
    $end = $per_page;
    }
    // display pagination
    $page = intval($_GET['page']);
    $tpages=$total_pages;
    if ($page <= 0)
    $page = 1;
      $reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages;
 
// display data in table
 
// loop through results of database query, displaying them in the table
for ($i = $start; $i < $end; $i++) {
// make sure that PHP doesn't try to show results that don't exist
if ($i == $total_results) {
break;
}
echo "<div style='float:left;width:150px;padding-left:10px;padding-right:10px;height:200px;padding-bottom:50px;vertical-align:top'>";
$IdPhoto = mysql_result($result, $i, 'IdPhoto');
 
if (empty($IdPhoto))
{
	?>
 <div style="margin-top:5px;height:100px"><img src="<?php $_SERVER['DOCUMENT_ROOT'];?>/frimousse/dataimg/not-found.jpg" width="120px"></div><br />
 <?php
} else {
?>
<div style="margin-top:5px;height:100px"><img src="<?php $_SERVER['DOCUMENT_ROOT'];?>/frimousse/dataimg/i<? echo $IdPhoto ?>.jpg" width="120px" style="padding-bottom:10px"></div><br />
 
<?php 
 }
 $Titre = utf8_encode(mysql_result($result, $i, 'Titre'));
// echo out the contents of each row into a table
echo '<div style="margin-top:5px;height:35px">' . $Titre . '</div><br />';
echo '<div style="margin-top:-15px;height:20px">' . $cat . '</div><br />';
echo '<div style="margin-top:5px">' . mysql_result($result, $i, 'AgeVise') . '</div><br /></div>';
}
// close table>
echo "<div style='clear:both'></div>";
echo '<div class="pagination"><ul>';
if ($total_pages > 1) {
echo paginate($reload, $show_page, $total_pages);
}
echo "</ul></div>";
// pagination
 
    ?>
Tout va bien jusqu'au changement de page: dès que je change de page je pers ma liste de résultats.

Pouvez-vous m'aider ou du moins me dire comment corriger le problème?

Merci beaucoup.