Jump to content


This topic is now archived and is closed to further replies.


checking if a feild was empty

Recommended Posts

Hey i'm doing a search, and im trying to figure out how to check if the feild was empty (if they just hit search and put nothing in the input feild in the form).

heres my following code when the user submits the form


$_SESSION['access'] = true;
$keyword = strip_tags(stripslashes($_POST['search']));
$newkey = $keyword . '_KW';
//the query it's self
//$query = "SELECT * FROM catalogue WHERE `keywords`='$newkey'" ;
//The following takes the input from the feild and compares it to the values in keywords.
//The next section is to take the id's of each result, and display them with their thumbnail image
$_SESSION['keyword'] = $newkey;
$query = "SELECT * FROM catalogue WHERE `keywords` LIKE '%$newkey%'";
  //$query = "SELECT * FROM catalogue WHERE `keywords`='$keyword'";
$result = mysql_query($query);

if(mysql_num_rows($result) >= 1){
$x = 0;
while($rows = mysql_fetch_assoc($result)){
$values[$x] =  $rows['identifier'];
$_SESSION[$x] = $values[$x];
// echo $rows['identifier'] . '<br/>';

//$sqlquery = 

} else {
echo "No results have been found";


What im trying to do is, check if its empty if so, set a message or something like that.

If it isnt, and there is a proper value, do the mysql queries etc.

Can anyone steer me in the right direction?


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.