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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| <?php
//Connexion à la base de données
include("includes/connect_db.php");
//Initialisation de la variable contenant les résultats
$resultats = "";
// $nbreParametres = 2; // Nombre de paramètres à renseigner
//Traitement de la requête
if(isset($_POST['query']) && !empty($_POST['query'])){
//Si l'utilisateur a entré quelque chose, on traite sa requête
//On rend clean la requête de l'utilisateur
$query = preg_replace("#[^a-z ?0-9]#i", "", $_POST['query']);
$sql_search = "SELECT u.id, u.fname, u.lname, a.acc_no, a.balance, a.status, a.bdate, a.type, a.id AS acc_id
FROM tbl_users u, tbl_accounts a
WHERE u.id = a.user_id AND a.acc_no LIKE ?";
$req = $db->prepare($sql_search);
// if($nbreParametres == 2){
$req->execute(array('%'.$query.'%', '%'.$query.'%'));
/* } else {
$req->execute(array('%'.$query.'%', '%'.$query.'%', '%'.$query.'%', '%'.$query.'%'));
} */
$count = $req->rowCount();
if($count >= 1){
echo "$count résultat(s) trouvé(s) pour <strong>$query</strong><hr/>";
while($data = $req->fetch(PDO::FETCH_OBJ)){
echo '<div id="errorCls" style="color:#FF0000 !important;font-size:14px;font-weight:bold;"><?php echo $errorMessage; ?></div>';
echo '<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="text">';
echo '<tr align="center" id="listTableHeader">';
echo '<td>User Name</td>';
echo '<td>Account No.</td>';
echo '<td>Balance</td>';
echo '<td width="120">Account Type</td>';
echo '<td width="80">Account status</td>';
echo '<td width="70">Statement</td>';
echo '</tr>';
<?php
while($row = dbFetchAssoc($result)) {
extract($row);
if ($i%2) {
$class = 'row1';
} else {
$class = 'row2';
}
$i += 1;
$atype = "";
if($type == "CA"){$atype = "Checking Account";}
else if($type == "SA") {$atype = "Saving Account";}
else if($type == "FDA") {$atype = "Fixed deposit Account";}
?>
echo '<tr class="<?php echo $class; ?>">';
echo '<td><?php echo $fname .' '.$lname; ?></td>';
echo '<td><div align="center"><a href="<?php echo WEB_ROOT; ?>cheg/account/?view=detail&accId=<?php echo $acc_id; ?>"><?php echo $acc_no; ?></a></div></td>';
echo '<td><div align="center">$ <?php echo $balance; ?></div></td>';
echo '<td width="120" align="center"><?php echo $atype; ?></td>';
echo '<td width="80" align="center">
<a href="javascript:changeAccStatus(<?php echo $acc_id; ?>, '<?php echo $status; ?>');">
<?php echo $status == 'INACTIVE'? 'Inactive' : 'Active'; ?>
</td>';
echo '<td width="70" align="center"><a href="javascript:viewAccountStatement(<?php echo $id; ?>, <?php echo $acc_no; ?>);">Statement</a></td>';
echo '</tr>';
<?php
} // end while
?>
echo '<tr>';
echo '<td colspan="5"> </td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan="5" align="right"></td>';
echo '</tr>';
echo '</table>';
echo '<p> </p>';
}
echo '<hr/>';
} else {
echo "Il n'y a aucun résultat trouvé pour le Numéro de compte: <strong>$query</strong><hr/>";
}
}
<!DOCTYPE html>
<html>
<head>
<title>Moteur de Recherche</title>
<meta charset="UTF-8" />
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="search" name="query" placeholder="Rechercher un Numéro de compte..." /><br/>
</form>
<?php echo $resultats; ?>
</body>
</html>
?> |
Partager