Pagination : liste deroulante

Fermé
sabrine - 28 mars 2014 à 10:06
 sabrine - 28 mars 2014 à 12:29
bnjour a tous svp aider moi :
j ai deux listes derouantes dinamiques apres avoir selectioner la valeur de la deusiémme liste deroulante et avoir appyer sur un bouton un tableu s afficheras j ai realiser la pagination pour cette tableau alors la lorsque je clique par exemple sur le liein da la page deux la elle ne m affiche pas le contenue de la table directement mais je me suis force a encore faire la meme choix que au debuit via les listes deroulantes pour q'elle m affiche le contenue de la table coment pourrais je eviter se probléme merci d avance









<table>	
			 
		<tr>
			   <td>
			   <font size="4"><b>View report booking by :</b></font>
			   </td>
			   </tr>
			   <tr>
			   <td>
			   <select name="type">
			                           
			                            <option value="">--Select--</option>
			                           
										<option value="cipoperator">Cip Operator</option>
										<option value="ServiceName">Service Name</option> 
										<option value="AirlineCompany">Airline Company </option>
										<option value="destination">Destination </option>
										</select>
										<input type="submit" name="valider" value=" view Report"></td></tr>  <?php
										
	if(isset($_POST['valider']))
	 {
	 $value=$_POST['type'];
	 if($value=='cipoperator')
	 {
	$select='SELECT DISTINCT cipoperator FROM clients order by  cipoperator ';
				 $result = mysql_query($select) or die ('Erreur : '.mysql_error() );
                  $total = mysql_num_rows($result);

				  echo'<tr><td>choose your Cip Operator :</td><td><select name="cip"><option>---select---</option>';
				              if($total) {
				   
	                              while($row = mysql_fetch_array($result)) {
                                     echo"<option>".$row['cipoperator']."</option>";
                                     
	                                                           }								
                             }
							 echo"</select> <input type=\"submit\" name=\"valider1\" value=\"view\"></td></tr>";

							 
							 
							
							 }
							 }
							  if(isset($_POST['valider1']))
	 {
	        $value=$_POST['cip'];
			 $select= mysql_query("SELECT Name,Surname,Date,Assisted_By,cipoperator FROM clients WHERE cipoperator='".$value."'");
                  $nr = mysql_num_rows($select);
				  				  if (isset($_GET['pn'])) { 
    $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); 
} else { 
    $pn = 1;
}
$itemsPerPage = 10; 
$lastPage = ceil($nr / $itemsPerPage);
if ($pn < 1) { 
    $pn = 1; 
} else if ($pn > $lastPage) { 
    $pn = $lastPage; 
} 
$centerPages = "";
$sub1 = $pn - 1;
$sub2 = $pn - 2;
$add1 = $pn + 1;
$add2 = $pn + 2;
if ($pn == 1) {
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a>  ';
} else if ($pn == $lastPage) {
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a>  ';
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
} else if ($pn > 2 && $pn < ($lastPage - 1)) {
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a>  ';
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a>  ';
} else if ($pn > 1 && $pn < $lastPage) {
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a>  ';
    $centerPages .= '  <span class="pagNumActive">' . $pn . '</span>  ';
    $centerPages .= '  <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a>  ';
}
$limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; 
			 $select="SELECT Name,Surname,Date,Assisted_By,cipoperator FROM clients WHERE cipoperator='".$value."'$limit";
			  $result1 = mysql_query($select) or die ('Erreur : '.mysql_error() );
                  $total = mysql_num_rows($result1);
				  $paginationDisplay = ""; 
if ($lastPage != "1"){
    if ($pn != 1) {
        $previous = $pn - 1;
        $paginationDisplay .=  '   <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> ';
    } 
    
    $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>';
    if ($pn != $lastPage) {
        $nextPage = $pn + 1;
        $paginationDisplay .=  '   <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> ';
    } 
}

////////////
				  ?><?php 							  $outputList = '';
				              if($total) {

				   ?> <br><!--startprint--><table border="2" align="center"><tr><?php echo'<br><b>the report of the Cip Operator : <font color="red">'.$value.'</font></b><br><br>';?></tr><tr><td>Cip Operator</td><td>Name</td><td> Surname</td><td> Date</td><td> Assisted_By</td></tr>
				
	                              <?php    while($row = mysql_fetch_array($result1)) {
                                       
                                       $outputList .= '<tr><td>'.$row['cipoperator'].'</td><td>'.$row["Name"].'</td><td>'.$row['Surname'].'</td><td>'.$row["Date"].'</td><td>'.$row["Assisted_By"].'</td></tr>';
	                                                             }
                             

							 }
							 							             print "$outputList"; 
          echo $paginationDisplay; 
}

							 
							 



							 ?>
	 
      
	 </table><!--endprint-->

	      <?php

1 réponse

quelqu'un pour m aider svp
0