#SEARCH BOX HELP

4 messages · Page 1 of 1 (latest)

vale elbow
#

I have an html web site that has a lot of costumes in it. I need to create a search box that will look through all the costumes and display the one that match. Say "Santa" and display all the Santa costumes. Site is costumebarn.biz I made a couple attempts but is just would not search. I prefer not to use google. Can someone show me the correct code that will work and where I should place it? Thanks, 😄

red yarrow
# vale elbow I have an html web site that has a lot of costumes in it. I need to create a sea...

You will need back-end code for this and a database, store all products in a database then write a back-end script with a SQL Query to look through the database.

For example, you could use php
Something like

<?php
$conn = mysqli_connect("127.0.0.1", "root", "password", "store");

$name = "%" . $_POST['name'] . "%";
$stmt = $conn->prepare("SELECT * FROM store_table WHERE name LIKE ?");
$stmt->bind_param("s", $name);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows > 0) {
  while($row = $result->fetch_assoc()) {
    echo $row['name']."<br>";
  }
}
?>

Something like this should work

modest jewel
red yarrow
# modest jewel My tip: learn to build a modern website, not a 90s website (mysql + php). If you...

it is completly fine for a beginner to start off with php + mysql, you shouldn't really jump from 0 experience to the most advanced stuff that you can possibly do. you should start of with something simple, so php is perfect for this.

Sure, the end goal can of course be to use something better than php, but for a beginner, i would strongly recommend to start off with php and mysql...

php works just fine, and it is still the most used back-end language, but yeah it is used on the older websites, not the ones that are being created nowdays since there are better options now, but php is not so terribly bad, it works just fine honestly. If you are going to build a huge project let's say facebook 2.0 then yeah... you really shouldn't use php, but for a small simple project, php works just fine...