proceed();
function show_results($user_input, $nbr_lignes=0, $page=0) {
global $nb_per_page, $msg;
global $base_url;
global $caller;
global $charset;
global $empr;
global $callback;
$user_input = str_replace("*", "%", $user_input) ;
$where = "empr_nom like '$user_input%' ";
// on récupére le nombre de lignes qui vont bien
if(!$user_input) {
$requete = "SELECT COUNT(1) FROM empr ";
} else {
$requete = "SELECT COUNT(1) FROM empr WHERE $where ";
}
$res = pmb_mysql_query($requete);
$nbr_lignes = @pmb_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_cb, trim(concat(empr_cp,' ',empr_ville)) as lieu FROM empr ORDER BY empr_nom, empr_prenom LIMIT $debut,$nb_per_page ";
} else {
$requete = "SELECT id_empr, empr_nom, empr_prenom, empr_cb, trim(concat(empr_cp,' ',empr_ville)) as lieu FROM empr WHERE $where ";
$requete .= "ORDER BY empr_nom, empr_prenom LIMIT $debut,$nb_per_page ";
}
$res = @pmb_mysql_query($requete);
while(($empr=pmb_mysql_fetch_object($res))) {
$empr_entry = $empr->empr_nom;
if($empr->empr_prenom) $empr_entry .= ', '.$empr->empr_prenom;
print pmb_bidi("
id_empr', '".htmlentities(addslashes($empr_entry),ENT_QUOTES, $charset)." ($empr->empr_cb)','$callback')\">
$empr_entry");
print pmb_bidi(' '.$empr->lieu.' ('.$empr->empr_cb.')');
print "
";
}
pmb_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 '