Jump to content

simple search query


newsamsu

Recommended Posts

You'd use like statements in the query.

 

<?php
$search_str = "bob";

$query = "SELECT `name` FROM `users` WHERE LOWER(`name`) LIKE LOWER('%$search_str%')";
$run = mysql_query($query);
if($run){
   while($arr = mysql_fetch_assoc($run)){
      extract($arr);
      echo "name = $name<br />";
   }
}
else{
   die("Unable to connect to database.");
}
?>

 

This is obviously a very simple example, but it's enough to get you started.

Link to comment
https://forums.phpfreaks.com/topic/100525-simple-search-query/#findComment-514167
Share on other sites

Archived

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

×
×
  • Create New...

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.