Jump to content
Larry Ullman's Book Forums

Select Link and product search


Recommended Posts

Dear All,

 Please, help me to resolve these two issues:

1) How can I change this list link to select link

 echo "
             <li>
                 <a href='shop.php?cat=$cat_id'> $cat_title </a>
              </li>
            ";

I tried this

 echo "
<option><a href='shop.php?p_cat=$p_cat_id'> $p_cat_title </a></option>
 ";     but the link is not working

2)  please, how can I perform FULLTEXT SEARCH WITH JOINS?  I consulted php and Mysql for dynamic website 5th edition and use this 

select * from products where MATCH (product_keywords, product_desc, product_title, product_features)  AGAINST ('%$search_query%' IN BOOLEAN MODE

it works but anytime I added another table

 SELECT products.*,sizes.size FROM products LEFT JOIN sizes ON products.size_id = sizes.size_id where MATCH (product_keywords, product_desc, product_title, product_features, sizes.size) AGAINST ('%28FF%' IN BOOLEAN MODE)

it was saying #1210 - Incorrect arguments to MATCH

Link to comment
Share on other sites

As far as I know, the only way to make a SELECT work as a list of links is to use JavaScript to redirect the browser upon changing or selecting an item in the list. I don't think that's something you want to do. 

As for your MATCH...AGAINST, you probably don't have a fulltext index set on sizes.size, which could cause that error. 

Link to comment
Share on other sites

Thanks very much, What I actually wanted to do with #1 questions is to display the product categories that when customer select on categories it will show them all the products under that categories, I know how to do it using list link but because I want the select input to be in header section like the screenshot below. My problem now is I don't know how to use Javascript to manipulate it, here is the full code

I want each option to take people to specific page when clicked

<select class="form-control" name="" id="prodcat">
                      
                      <option selected disabled>Product Categories</option>
                      
                      <?php
                        $get_p_cats = "select * from product_categories";
    
                        $run_p_cats = mysqli_query($dbc,$get_p_cats);
                        
                        while($row_p_cats=mysqli_fetch_array($run_p_cats)){
                            
                            $p_cat_id = $row_p_cats['p_cat_id'];
                            
                            $p_cat_title = $row_p_cats['p_cat_title'];
                            
                            echo "

                           
                            <option><a href='shop.php?p_cat=$p_cat_id'> $p_cat_title </a></option>
                           
                            ";
                            
                        } 
                        
                    
                    ?>
                   
                      
                      
                    </select>
 

categorieslink.JPG

Link to comment
Share on other sites

Okay, two ways of going about this. The first is to make a SELECT menu whose option value is the category ID and then you add the JavaScript that redirects the browser when the selection changes. Alternatively you could create an unordered list of links that's collapsed into one menu using JavaScript and CSS. I think the later is likely more common.

Link to comment
Share on other sites

Thanks sir,

I wrote the code like below and it works 

<select class="form-control" name="prodoccat" onchange="location = this.value;" id="prodcat">
                      
                      <option selected disabled>Product Categories</option>
                      
                      <?php

                        $get_p_cats = "select * from product_categories";
    
                       $run_p_cats = mysqli_query($dbc,$get_p_cats);
    
                    while($row_p_cats=mysqli_fetch_array($run_p_cats)){
        
                  $p_cat_id = $row_p_cats['p_cat_id'];
        
             $p_cat_title = $row_p_cats['p_cat_title'];
        
           echo "
        
        <option value='shop.php?p_cat=$p_cat_id'> $p_cat_title </option>
        
        ";
        
    }
    
}
                        
                    
                    ?>

Link to comment
Share on other sites

 Share

×
×
  • Create New...