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
|
<?php
$serveur='localhost';
$user='root';
$motdepasse='';
$bdd='moteur';
$connect= mysql_connect($serveur,$user,$motdepasse) or die ("Impossible de se connecter: ");
mysql_select_db($bdd);
?>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<head>
<title></title>
</head>
<body>
<div id="content">
<form action="index.php" method="post">
<label for="search">Rechercher :</label>
<select name="search" >
<?php
$result = mysql_query("SELECT titre FROM moteur");
while ($row = mysql_fetch_array($result))
{
echo '<option value="'.$row["titre"].'">'.$row["titre"].'</option>';
}
?>
<input type="submit" value="Rechercher" />
</form>
<?php
if(isset($_POST['type'])){
echo $search;
$req = mysql_query("SELECT * FROM moteur WHERE titre LIKE '%$search%' OR contenu LIKE '%$search%' ORDER BY id");
if($req->rowCount()>0)
{
while($data = $req->fetch(PDO::FETCH_OBJ))
{
echo '<h2>'.$data->titre.'</h2>';
echo '<p>'.$data->contenu.'</p>';
}
}
else
{
echo '<h2>Aucun resultat</h2>';
}
}
?>
</div>
</body>
</html> |
Partager