• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Search on 1 page (WP)

dondiego

Member
May 24, 2022
48
8
8
Hi all,

I have a WP website with the Enfold theme, which rents out things like snowchains.

For the snowchains I'm looking for a plugin or script with a search function.

So visitors should typ in the tyre size, like : 225 / 50 / 16

And then the snowchains which match should appear. Or not if there is no snowchain available in our product range.
Does anyone know if there is something available for a plugin or script?

Thank you in advance.

Diego
 
This is not a request, so moved to more appropriate section.
 
  • Like
Reactions: dondiego
Here is a smaple of what you can do!

This code connects to your database, gets the search query from the user (in this case the tire size), queries the database for snowchains that match the tire size, and displays the results to the user. You will need to modify this code to match the structure of your database and the names of your snowchain products and attributes.

Name it search.php

Code:
<?php
// Connect to your database
$conn = mysqli_connect('localhost', 'username', 'password', 'database');

// Get the search query from the user
$tire_size = $_GET['tire_size'];

// Query the database for snowchains that match the tire size
$query = "SELECT * FROM snowchains WHERE tire_size LIKE '%$tire_size%'";
$result = mysqli_query($conn, $query);

// Display the search results to the user
if(mysqli_num_rows($result) > 0) {
  while($row = mysqli_fetch_assoc($result)) {
    echo "<h2>".$row['product_name']."</h2>";
    echo "<p>Tire Size: ".$row['tire_size']."</p>";
    echo "<p>Price: ".$row['price']."</p>";
  }
} else {
  echo "No snowchains match your search criteria.";
}

// Close the database connection
mysqli_close($conn);
?>


You will need a form for the users to use

form.html

Code:
<!DOCTYPE html>
<html>
  <head>
    <title>Snow Chain Search</title>
  </head>
  <body>
    <h1>Snow Chain Search</h1>
    <form action="search.php" method="get">
      <label for="tire_size">Tire Size:</label>
      <input type="text" name="tire_size" id="tire_size">
      <button type="submit">Search</button>
    </form>
  </body>
</html>

Now you need to create a database and add this to the PHPMYADMIN
 
Here is a smaple of what you can do!

This code connects to your database, gets the search query from the user (in this case the tire size), queries the database for snowchains that match the tire size, and displays the results to the user. You will need to modify this code to match the structure of your database and the names of your snowchain products and attributes.

Name it search.php

Code:
<?php
// Connect to your database
$conn = mysqli_connect('localhost', 'username', 'password', 'database');

// Get the search query from the user
$tire_size = $_GET['tire_size'];

// Query the database for snowchains that match the tire size
$query = "SELECT * FROM snowchains WHERE tire_size LIKE '%$tire_size%'";
$result = mysqli_query($conn, $query);

// Display the search results to the user
if(mysqli_num_rows($result) > 0) {
  while($row = mysqli_fetch_assoc($result)) {
    echo "<h2>".$row['product_name']."</h2>";
    echo "<p>Tire Size: ".$row['tire_size']."</p>";
    echo "<p>Price: ".$row['price']."</p>";
  }
} else {
  echo "No snowchains match your search criteria.";
}

// Close the database connection
mysqli_close($conn);
?>


You will need a form for the users to use

form.html

Code:
<!DOCTYPE html>
<html>
  <head>
    <title>Snow Chain Search</title>
  </head>
  <body>
    <h1>Snow Chain Search</h1>
    <form action="search.php" method="get">
      <label for="tire_size">Tire Size:</label>
      <input type="text" name="tire_size" id="tire_size">
      <button type="submit">Search</button>
    </form>
  </body>
</html>

Now you need to create a database and add this to the PHPMYADMIN
Thank you!

But how do I place this into a Wordpress site with Enfold Theme?
Sorry I'm a newbie......
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock