Created
February 6, 2011 21:02
-
-
Save anonymous/813716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!empty($_POST)&& !empty($_POST['search'])) | |
{ | |
extract($_POST); | |
$search = strip_tags($search); | |
try{ | |
$bdd = new PDO ('mysql:host=localhost;dbname=articles', 'aimeric','roffbmw94') or die(print_r($bdd->errorInfo())); | |
$bdd->exec('SET NAMES utf8');} | |
catch(exeption $e){ | |
die('Erreur:'.$e->getMessage()); | |
} | |
$req = $bdd->query("SELECT titre, contenu FROM articles 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>'; | |
echo '<hr/>'; | |
} | |
} | |
else | |
{ | |
echo '<h2> Aucun resultat</h2>'; | |
} | |
} | |
else | |
{ | |
echo '<h2> Aucun resultat</h2>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment