Skip to content
Advertisement

Search query by size in PHP

I want my site to search for any product that belonged to particular size when clicked any size option in the select input menu on mobile version like shop by size menu in www.brastop.com on mobile version. My problem is on how to extract size variable from option tag and put it in the select query in sizeresult.php. below are my codes:

  1. for select menu
JavaScript

my problem is how to extract the $size_name from option tag and put it in between the two single quotes after the WHERE CLAUSE on the first line in the next code snipet where I wrote sizes.size = =’%$size_name%’

for sizeresult.php

JavaScript

Advertisement

Answer

Here are things you can do to fix your code.

  1. write your form as following.

    JavaScript
  2. add the following line right above $run_products = mysqli_query(… in sizeresults.php file.

    $size_name=$_POST['size']; //used to get the value of option to be used in query.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement