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 81 82 83 84
| <?php
session_start ();
$_session['mot'] = $_POST['mot'];
$_session['categorie'] = $_POST['categorie'];
$_session['secteur'] = $_POST['secteur'];
include('config.php');
include ('pagination.php'); //include of paginat page
$per_page = 6; // number of results to show per page
if (isset($_session['categorie'])) {
$result = mysql_query("SELECT * FROM csvdata where categorie={$_session['categorie']}");
}
elseif (isset($_session['secteur'])){
$result = mysql_query("SELECT * FROM csvdata where secteur={$_session['secteur']}");
}
elseif (isset($_session['mot'])){
$result = mysql_query("SELECT * FROM csvdata where titre={$_session['mot']}");
}
$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
?> |
Partager