"; $sel_loc .= ""; while($loc = mysql_fetch_object($res_loc)){ $sel_loc .= ""; } $sel_loc.= ""; $sel_search_form = str_replace("!!sel_loc!!",$sel_loc, $sel_search_form); } else $sel_search_form = str_replace("!!sel_loc!!","", $sel_search_form); // affichage des membres de la page $sel_search_form = str_replace("!!deb_rech!!", stripslashes($f_user_input), $sel_search_form); print $sel_search_form; print $jscript; show_empr_results($dbh, $user_input, $nbr_lignes, $page); } else { // affichage du header $sel_header = str_replace('!!is_current_user!!', "class='sel_navbar_current'", $sel_header); $sel_header = str_replace('!!is_current_empr!!', '', $sel_header); print $sel_header; // affichage des membres de la page $sel_search_form = str_replace("!!deb_rech!!", stripslashes($f_user_input), $sel_search_form); $sel_search_form = str_replace("!!sel_loc!!","", $sel_search_form); print $sel_search_form; print $jscript; show_user_results($dbh, $user_input, $nbr_lignes, $page); } break; } function show_empr_results($dbh, $user_input, $nbr_lignes=0, $page=0) { global $nb_per_page; global $base_url; global $caller; global $charset; global $tab_poids; global $empr_loca; $user_input = str_replace("*", "%", $user_input) ; if(strpos($user_input,',') !== false){ $tab_input = explode(",", $user_input); $where = "empr_prenom like '%".$tab_input[0]."%' or empr_nom like '%".$tab_input[1]."%'"; } else { $where = "empr_prenom like '%".$user_input."%' or empr_nom like '%".$user_input."%' or empr_cb like '%".$user_input."%'"; } if($empr_loca){ $where_loc = " empr_location='$empr_loca' "; } else { $where_loc =""; } // on récupére le nombre de lignes qui vont bien if(!$user_input) { $requete = "SELECT COUNT(1) FROM empr ".( $where_loc ? "WHERE ".$where_loc :""); } else { $requete = "SELECT COUNT(1) FROM empr WHERE ( $where ) ".( $where_loc ? "AND ".$where_loc :""); } $res = mysql_query($requete, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); if(!$page) $page=1; $debut =($page-1)*$nb_per_page; if($nbr_lignes) { // on lance la vraie requête if(!$user_input) { $requete = "SELECT id_empr, empr_nom, empr_prenom, empr_location FROM empr ".( $where_loc ? "WHERE ".$where_loc :"")." ORDER BY empr_nom, empr_prenom LIMIT $debut,$nb_per_page "; } else { $requete = "SELECT id_empr, empr_nom, empr_prenom FROM empr WHERE ( $where ) ".( $where_loc ? "AND ".$where_loc :""); $requete .= "ORDER BY empr_nom, empr_prenom LIMIT $debut,$nb_per_page "; } $res = @mysql_query($requete, $dbh); while(($empr=mysql_fetch_object($res))) { $empr_entry = $empr->empr_nom; if($empr->empr_prenom) $empr_entry = $empr->empr_prenom.' '.$empr_entry; $location = ( $empr->empr_location ? $empr->empr_location : $em); print pmb_bidi(" id_empr', '".htmlentities(addslashes($empr_entry),ENT_QUOTES, $charset)."', '1', '".$tab_poids[1]."','".$location."') \"> $empr_entry"); print "
"; } mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes/$nb_per_page); $suivante = $page+1; $precedente = $page-1; // affichage du lien précédent si nécéssaire print '
'; if($user_input == '%') $user_input = "*"; if($precedente > 0) print "[$msg[48]]"; for($i = 1; $i <= $nbepages; $i++) { if($i==$page) print "$i/$nbepages"; } if($suivante<=$nbepages) print "[$msg[49]]"; } print '
'; } function show_user_results($dbh, $user_input, $nbr_lignes=0, $page=0) { global $nb_per_page; global $base_url; global $caller; global $charset; global $tab_poids; $user_input = str_replace("*", "%", $user_input) ; if(strpos($user_input,',') !== false){ $tab_input = explode(",", $user_input); $where = "prenom like '%".$tab_input[0]."%' or nom like '%".$tab_input[1]."%'"; } else { $where = "prenom like '%".$user_input."%' or nom like '%".$user_input."%'"; } // on récupére le nombre de lignes qui vont bien if(!$user_input) { $requete = "SELECT COUNT(1) FROM users "; } else { $requete = "SELECT COUNT(1) FROM users WHERE $where "; } $res = mysql_query($requete, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); if(!$page) $page=1; $debut =($page-1)*$nb_per_page; if($nbr_lignes) { // on lance la vraie requête if(!$user_input) { $requete = "SELECT userid, nom, prenom FROM users ORDER BY nom, prenom LIMIT $debut,$nb_per_page "; } else { $requete = "SELECT userid, nom, prenom FROM users WHERE $where "; $requete .= "ORDER BY nom, prenom LIMIT $debut,$nb_per_page "; } $res = @mysql_query($requete, $dbh); while(($row_user=mysql_fetch_object($res))) { $user_entry = $row_user->nom; if($row_user->prenom) $user_entry = $row_user->prenom.' '.$user_entry; print pmb_bidi(" userid', '".htmlentities(addslashes($user_entry),ENT_QUOTES, $charset)."', '0', '".$tab_poids[0]."' )\"> $user_entry"); print "
"; } mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes/$nb_per_page); $suivante = $page+1; $precedente = $page-1; // affichage du lien précédent si nécéssaire print '
'; if($precedente > 0) print "[$msg[48]]"; for($i = 1; $i <= $nbepages; $i++) { if($i==$page) print "$i/$nbepages"; } if($suivante<=$nbepages) print "[$msg[49]]"; } print '
'; } print $sel_footer;