-3

i have a page that display stores.Every store has a picture and name. I want to make search box by store name and when user clicks submit .only the store with searched name is displayed. in the database they are found in table (stores) and stored in a column (s_name) i tried many times and give me error please can any one writes the php code for this search

`

                if(isset($_post['submit'])){
                    $db = new mysqli("localhost","root","rootroot","r");
                $search = $db->real_escape_string($_post['search']);
                $resultset = $db->query("SELECT * FROM stores WHERE s_name = 
                                                               '$search'");
                }

                ?>



                <form method="post">
                <input type="text" name="search"/>
                <input type="submit" name="submit" value="search"/>
                </form>

                `
rixxkenzou
  • 21
  • 5

1 Answers1

-1

This should do the trick.

$search = mysqli_real_escape_string($db, $_POST['search']);
$sql = 'SELECT * FROM stores WHERE s_name="'.$search.'"';
$result = mysqli_query($db, $sql);
Jeppesen
  • 64
  • 5