Well, I am making a game website and I have a search bar where the user types the game he wants to find. I have something like this (this is a test, don't need to block sql injection):
<?php
if ($_REQUEST['search']){
$searched = $_POST['searched'];
$gamesearched = mysql_query("SELECT * from games WHERE name like '%$searched%'");
while($write=mysql_fetch_array($gamesearched)){
echo "Found it!"
}
}else{
echo "Search something";
}
?>
I can't use an else to the while statement so how would I do to show something like "No games where found".
I am trying to use this but doesn't work :P
while(($write=mysql_fetch_array($gamesearched)) != null){
echo "found";
}else{
echo "not found";
}