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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| <?php
mysql_connect("localhost","root") or die("erreur de connexion au serveur $host");
mysql_select_db("test_2");
//recherche des résultats dans la base de données
if(isset($_POST['recherche']))
{
$where = array();
if (!empty($_POST['idsiteinterne']))
$where[] = "idsiteinterne LIKE '%".htmlentities(trim($_POST['idsiteinterne']))."%'";
if (!empty($_POST['idsiteprovider']))
$where[] = "idsiteprovider LIKE '%".htmlentities(trim($_POST['idsiteprovider']))."%'";
if (!empty($_POST['idetatsite']))
$where[] = "idetatsite='".htmlentities(trim($_POST['idetatsite']))."'";
if (!empty($_POST['site_name']))
$where[] = "site_name LIKE '%".htmlentities(trim($_POST['site_name']))."%'";
if (!empty($_POST['adresseIP']))
$where[]= "adresseIP LIKE '%".htmlentities(trim($_POST['adresseIP']))."%'";
if (!empty($_POST['service']))
$where[] = "service LIKE '%".htmlentities(trim($_POST['service']))."%'";
if(sizeof($where) > 0)
{
// "on peut rechercher soit par le nom, par le prénom, par adresse ainsi de suite..."
$sqlWhere = ' WHERE '.implode(' AND ', $where);
$req = "SELECT id, idsiteinterne, idsiteprovider, site_name, adresseIP, service, idetatsite FROM cyb_site ".$sqlWhere. " LIMIT 10;";
echo '<div class="article-result">';
echo'<h4>Resultat de recherche</h4>';
$result = mysql_query($req) or die('Erreur SQL !'.$req.'<br /><b>'.mysql_error().'</b>');
if ( mysql_num_rows( $result ) == 0 )
{ echo '<h3 style="text-align:center; margin:10px 0;">Pas de résultats pour cette recherche</h3>'; }
else
{
echo "<table>";
echo '<tr>';
echo '<th class="td_seach_titre">N°</th>';
echo '<th class="td_seach_titre">ID Provider</th>';
echo '<th class="td_seach_titre">ID Interne</th>';
echo '<th class="td_seach_titre">Nom du site</th>';
echo '<th class="td_seach_titre">Adresse IP</th>';
echo '<th class="td_seach_titre">Service</th>';
echo '<th class="td_seach_titre">Etat du site</th>';
echo '</tr>';
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo '<td class="id">'.$row['id'].'</td>';
echo '<td class="td_seach">'.$row['idsiteinterne'].'</td>';
echo '<td class="td_seach">'.$row['idsiteprovider'].'</td>';
echo '<td class="td_seach">'.$row['site_name'].'</td>';
echo '<td class="td_seach">'.$row['adresseIP'].'</td>';
echo '<td class="td_seach">'.$row['service'].'</td>';
echo '<td class="td_seach">'.$row['idetatsite'].'</td>';
echo "</tr>";
}
echo "</table>";
}
echo "</div>";
}else{ echo 'Vous devez remplir au moins un des champs de recherche !'; }
}
?>
<div id="boxManage">
<h4>Rechercher un site</h4>
<p>Trouvez un site par son nom, sa date de création, son ID, son statut. </p>
<form method="POST" action="">
<table width="480" border="0" class="right">
<tr>
<td class="recherche_text"><label for="id_interne">ID interne</label></td>
<td > <input type="text" name="idsiteinterne" class="recherche" id="id_interne" value="<?php if (isset($_POST['idsiteinterne'])) echo htmlentities(trim($_POST['idsiteinterne'])); ?>"></td>
</tr>
<tr>
<td class="recherche_text"><label for="id_provider" >ID Provider</label></td>
<td>
<input type="text" name="idsiteprovider" class="recherche" id="id_provider" value="<?php if (isset($_POST['idsiteprovider'])) echo htmlentities(trim($_POST['idsiteprovider'])); ?>">
</td>
</tr>
<tr>
<td class="recherche_text"><label for="nom_du_site">Nom du site</label></td>
<td >
<input type="text" name="site_name" class="recherche" id="nom_du_site" value="<?php if (isset($_POST['site_name'])) echo htmlentities(trim($_POST['site_name'])); ?>">
</td>
</tr>
<tr>
<td class="recherche_text"> <label for="adresse_ip">Adresse IP</label></td>
<td >
<input type="text" name="adresseIP" class="recherche" id="adresse_ip" value="<?php if (isset($_POST['adresseIP'])) echo htmlentities(trim($_POST['adresseIP'])); ?>">
</td>
</tr>
<tr>
<td class="recherche_text">Statut</td>
<td class="seach_name" >
<SELECT name="idetatsite" class="recherche">
<OPTION>active</OPTION>
<OPTION>desactive</OPTION>
<OPTION>suspendu</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td colspan=2>
<input type="submit" name="recherche" class="recherche_submit" value="Rechercher" />
</td>
</tr>
</table>
</form>
</div> |
Partager