La recherche en PHP

Fermé
Melooo Messages postés 1405 Date d'inscription vendredi 28 novembre 2008 Statut Membre Dernière intervention 18 mars 2013 - 30 sept. 2010 à 12:17
Bonjour,

<?php
session_start();
include ('trace_ip.php');
include ('connexion_bd.php');
include ('fonction.php');


function dh($t)
{
	if ($t == "")
	{
		return "__/__/__ __:__:__";
	}

	return redate(substr($t,0,10))." ".substr($t,11);
}

?>

												
														<form name="recherche" method="post" action="patients.php" >
															<fieldset>
															<LEGEND align="top"><font face="Calibri">Recherche d'un patient</font></LEGEND>
															<font face="Calibri">
															<table border="0">
															<tr>
															<td>Nom : </td><td><INPUT name="nom_propre" type="text" ></td>
																
															<td>Prénom : </td><td><INPUT name="prenom_pat" type="text"></td>
													
															<td>Actualisation : </td><td><input type="text" name="actu"></td>
															</tr>
															<tr>
															<td>Numéro sécurité sociale : </td><td><INPUT name="secu_pat" type="text"></td>
													
															<?php

$list_day = '<td><select name="day" id="day">';
$d = 1;
while($d <= 31){
	$list_day .= '<option value=""></option>';
 $list_day .= '<option value="'.str_pad($d, 2, 0, STR_PAD_LEFT).'">'.str_pad($d, 2, 0, STR_PAD_LEFT).'</option>';
 $d++;
}
$list_day .= '</select> ';

$list_month = '<select name="month">
	<option value=""></option>
    <option value="01">Janvier</option>
     <option value="02">Février</option>
     <option value="03">Mars</option>
     <option value="04">Avril</option>
     <option value="05">Mai</option>
     <option value="06">Juin</option>
     <option value="07">Juillet</option>
     <option value="08">Août</option>
     <option value="09">Septembre</option>
     <option value="10">Octobre</option>
     <option value="11">Novembre</option>
     <option value="12">Décembre</option>
</select></td>';

$list_year = '<td><select name="year">';
$y = date('Y');
while($y >= 1930){
$list_year .= '<option value=""></option>';
 $list_year .= '<option value="'.$y.'">'.$y.'</option>';
 $y--;
}
$list_year .= '</select></td>';

// test date:
													

/*$list_day = str_replace('value="'.$db_d.'"', 'value="'.$db_d.'" selected="selected"', $list_day);
$list_month = str_replace('value="'.$db_m.'"', 'value="'.$db_m.'" selected="selected"', $list_month);
$list_year = str_replace('value="'.$db_y.'"', 'value="'.$db_y.'" selected="selected"', $list_year);*/
echo '</td>';
echo '<td><label for="day" >Date de naissance</label></td>'.$list_day.$list_month.$list_year;

echo'</tr>';
$nombre = 1;  

// si limite n'existe pas on l'initialise à zéro

if (!$limite) $limite = 0; 

// on cherche le nom de la page.    

$path_parts = pathinfo($_SERVER['PHP_SELF']);

$page = $path_parts["basename"];


$select = 'SELECT count(USER_ID) FROM users, professionnels WHERE users.PROF_ID = professionnels.pro_id AND users.PROF_ID = '.$_SESSION['id_users'].'';

$result = mysql_query($select)  or die ('Erreur : '.mysql_error() );

$row = mysql_fetch_row($result);

$total = $row[0];
 // vérifier la validité de notre variable  $limite;

$verifLimite= verifLimite($limite,$total,$nombre);

// si la limite passée n'est pas valide on la remet à zéro

if(!$verifLimite)  {

    $limite = 0;

}
	$sql='select USER_SSID, USER_LASTNAME, USER_FIRSTNAME, USER_BIRDTHDAY, USER_ID, USER_ACTUALISATION from users, professionnels WHERE users.PROF_ID = professionnels.pro_id AND professionnels.pro_id = '.$_SESSION['id_users'].' ORDER BY USER_ID ASC limit '.$limite.','.$nombre;
	$exe = mysql_query($sql);

?>	
	</font>
	
														
													<td>&nbsp;</td>
													<td>&nbsp;</td>
												<td>	Trier par : <select name="triage" align="right">
															<option name="nom">Nom</option>
															<option name="prenom">Prénom</option>
															<option name="dn">Date de naissance</option>
															<option name="recent">Les plus récents</option>
															<option name="moins_recent">Les moins récents</option>
															<option name="dernier_consult">Les derniers consultés</option>
															</select></td>
											</form>		
									

															</fieldset>	
																<table onclick=    "javascript:doRecherche(this)"
																		onmousemove="javascript:setEffect('c1a',this);"
																		onmouseout= "javascript:setEffect('c1b',this);"
																		class="b1b"
																		align="right"
																		style="width:83;height:26;"
																		width="83"
																		height="26" cellpadding="0" cellspacing="0" border="0" cellborder="0">
															</table>
															<input type="submit" name="recherche" value="Recherche">

<?php
if(isset($_POST['recherche']))
{
if($_POST['triage'] == 'Nom')
{
	$tri = 'USER_LASTNAME';
}
else if($_POST['triage'] == 'Prénom')
{
	$tri = 'USER_FIRSTNAME';
}
else if ($_POST['triage'] == 'Date de naissance')
{
	$tri = 'USER_BIRDTHDAY';
}
else if ($_POST['triage'] == 'Les plus récents')
{
	$tri = 'USER_ACTUALISATION';
}
$user_nom = $_POST['nom_propre'];
$user_prenom = $_POST['prenom_pat'];
$user_secu = $_POST['secu_pat'];
$actu = $_POST['actu'];
$jour = $_POST['day'];
$mois = $_POST['month'];
$annee = $_POST['year'];
$date = $annee.'-'.$mois.'-'.$jour;
if ($date == "--")
{
	$date = "";
}
// initialisation des variables 

// on va afficher 5 résultats par page.


$sql='select USER_SSID, USER_LASTNAME, USER_FIRSTNAME, USER_BIRDTHDAY, USER_ID, USER_ACTUALISATION FROM users, professionnels WHERE professionnels.pro_id = '.$_SESSION['id_users'].' AND users.PROF_ID = professionnels.pro_id';
	

// Permet de rechercher le patient selon nom prenom secu date naiss
if ($user_nom != "" ) {
$sql .= " AND USER_LASTNAME like '%".$user_nom."%'";
}
if ($user_prenom != "" ) {
 $sql .= " AND USER_FIRSTNAME like '%".$user_prenom."%'";
 }
if ($user_secu != "" ) {
    $sql .= " AND USER_SSID like '%".$user_secu."%'";
}
if ($date != "" ) {
    $sql .= " AND USER_BIRDTHDAY like '%".$date."%'";
}
if ($actu != "" ) {
    $sql .= " AND USER_ACTUALISATION like '%".$actu."%'";
}
if(($user_nom != "") || ($user_prenom != "") || ($user_secu != "") || ($date != "") || ($actu != ""))
{
	$sql .= "ORDER BY '".$tri."' ASC";
}
$exe = mysql_query($sql);
}
?>															
														<br /><br />
	


											<form name="result"   action="result_recherche.php" method="post">
													<font face="Calibri">
 <?php if($total) {?>
														<table name="patient" align="center" cellspacing="8" cellpadding="15" border="0" bgcolor="white">
														  <tr align="center">
										<!-- MENU DE SOUS NAVIGATION -->
															<td class="nuage_secu" align="center" style="margin:auto;display:block;" valign="middle">&nbsp;</td>
															<td class="nuage_prenom"  style="margin:auto;vertical-align:middle;" align="center" valign="middle">&nbsp;</td>
															<td class="nuage_nom" style="margin:auto;" align="center" valign="middle">&nbsp;</td>
															<td class="nuage_naiss"  style="margin:auto;" align="center" valign="middle">&nbsp;</td>
															<td  class="nuage_actu" style="margin:auto;" align="center" valign="middle">&nbsp;</td>
															<td class="nuage_actions" style="margin:auto;display:block;" align="center" valign="middle">&nbsp;</td>
														</tr>
														 <?php 


														 while($row = mysql_fetch_array($exe)) {														
																	echo '<tr>';
																	echo '<td  align="center">'.$row[0].'</td>';
																	echo '<td  align="center">'.$row[2].'</td>';
																	echo '<td  align="center">'.$row[1].'</td>';
																	echo '<td  align="center">'.$row[3].'</td>';
																	echo '<td  align="center">'.$row[5].'</td>';
																	
?>
										<!-- ACTION -->
										</form>
																	<td>
																	<form name="constante" method="post" action="constante.php">
																	<input type="hidden" name="idusers" value="<?php echo $row[4];?>">
																	<INPUT border=0 src="Images/bouton_constante.png" type="image" Value="submit"> 
																	</form>
																	</td>
																	<td>
																	<form name="prescription" method="post" action="prescription.php">
																	<input type="hidden" name="idusers" value="<?php echo $row[4];?>">
																	<INPUT border=0 src="Images/bouton_prescription.png" type="image" Value="submit" > 
																	</form>
																	</td>
																	<td>
																	<form name="dossier" method="post" action="coordonnees.php">
																	<input type="hidden" name="idusers" value="<?php echo $row[4];?>">
																	<INPUT border=0 src="Images/bouton_dossier.png" type="image" Value="submit"> 
																	</form>
																

<br><?php
 echo '</table>'."\n";

}
else echo 'Pas d\'enregistrements dans cette table...';

mysql_free_result($exe);
 if($total > $nombre) {

    // affichage des liens vers les pages
echo "<center";
affichePages($nombre,$page,$total);
echo "</center>";
} ?>
														
																


J'ai une page avec un espace pour la recherche d'un patient, et un espace ou s'affiche tous les patients, un par page.
Lorsque j'utilise mon espace recherche tout va très bien, sauf qu'il m'affiche toujours les numéros des pages en dessous alors que je voudrais qu'il m'affiche seulement les patients en rapport avec ma recherche.
comment organiser ma nouvelle requête ?
Merci