Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. $output= '';
  3. if(isset($_POST['search_but'])){
  4. $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
  5. if (!$dbc){
  6. echo "i'm sorry we are experiencing technical issues<br />
  7. please try again soon<br />";
  8. }//end of if(!dbc)
  9. else{
  10. $search_term = $_POST['search'];
  11.  
  12. //query
  13. $query ="SELECT Product_Name, Price, RRP_Price, Description, Image_ID
  14. FROM products
  15. WHERE Product_Name LIKE '%$search_term%'
  16. " ;
  17.  
  18. $products = mysqli_query($dbc, $query);
  19. $count = mysqli_num_rows($products);
  20. if($count == 0){
  21. $output = 'there was no search results';
  22. }//end of if($count==0)
  23. else{
  24. while($row = mysqli_fetch_array($products));{
  25. $Product_Name = cleaner($row['Product_Name']);
  26. $Price = cleaner($row['Price']);
  27. $RRP_Price = cleaner($row['RRP_price']);
  28. $Description = cleaner($row['Description']);
  29. $output .= '<div>'.$Product_Name.' '.$Price.'</div>';
  30. }//end of while
  31. }//end of if($count==0)else
  32.  
  33.  
  34.  
  35. }//end of if(!dbc) else
  36. }//end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement