Jump to content

Boldonglen

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Boldonglen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have realised what the problem is and i am going to have to appologise for wasting your time. I was using the preg_replace() function to try and prevent SQL injection and this was taking the space out of the search term. Again im sorry but thank you for your help.
  2. This is exactly how my code is: $search_exploded = explode(' ',$search); $searches = array(); foreach($search_exploded as $search_each) { $searches[] = "keywords LIKE '%$search_each%'"; } $construct = "SELECT * FROM products WHERE " . implode(' OR ' , $searches); And the output of this when using "test test" is: SELECT * FROM products WHERE keywords LIKE '%testtest%' Have i copied the code wrong?
  3. I tried using this code but when i test to see what the queery will look like when using the search terms "test test" i get SELECT * FROM products WHERE keywords LIKE '%testtest%' This is not the queery i need to produce. i would want the queery to look something like SELECT * FROM products WHERE keywords LIKE '%test%' OR keywords LIKE '%test%'
  4. I have a foreach function within my website, it is used as part of a search engine i have created. The code was working and then i restarted my computer and now the code is not working. The code uses the explode function to separate each search term into an array. And then if there is more than one search term it adds a extra line of code onto the SQL query. If anyone could tell me why this is not working that would be a great help. $search_exploded = explode(" ",$search); $x = 0; foreach($search_exploded as $search_each) { $x++; if ($x==1) $construct .= "keywords LIKE '%$search_each%'"; else $construct .= " OR keywords LIKE '%$search_each%'"; } $construct = "SELECT * FROM products WHERE $construct"; Thanks Boldonglen Edit: I forgot to mention that what is happening is when i search for more than one term it is just showing the "SELECT * FROM products WHERE keywords LIKE '%$search_each%'" and not the OR statement. The $search_each is showing both the search results but just taking away the space.
  5. Yes the list of brands will be static they will not change they will be at the side of the website for the user to click on. The user does not have an input to what brand they have selected however im still unsure of how i would code the links.
  6. Im a little confused with the code that you supplied im not 100% with PHP The links that i have created are on every web page i have created and would like them all to link to one web page named product_list and for that page to be populated with the products of the brand selected. The code for my links are: <p><a href="product_list">Brand1</a></p> <p><a href="product_list">Brand2</a></p> <p><a href="product_list">Brand3</a> </p>
  7. I have tried messing around with my code but i cannot find a way of storing information after the user clicks a link. For example i have a list of brands on my website and each one has a hyperlink. When the user clicks the hyperlink i would like the name of that brand to be stored into a variable so that i can use the variable within the query. Could anyone help me out with this problem. Or recommend another solution to how i could show the products that are of the particular brand that the user clicks. Thanks Boldonglen
  8. Ok thanks a lot for your help. Ill mess around with my code and see if i can come up with anything that works if not ill leave a message on here. Again thanks. Boldonglen
  9. Yes i do have a brand field in my products table. I was thinking of using your first method however i was worried incase there was any way of the customer to hack into the database as they would have access to the query.
  10. I have designed and created a ecommerce website that allows the user to add products to a shopping cart and for the admin to edit the inventory list. However i would like to have a navigational bar on the website where the user can choose a brand of product and the webpage shows only that brand. I know i can do this by using the WHERE command in a query however would i have to make a separate web page for each brand? Thanks Boldonglen
  11. Thank you Crayon Violent This code works great! Big help. Thanks again. I will come back if i need anymore help. Thanks!!!!
  12. But my code is working fine to connect to a database. I do not need that previous code. I only need to know how to hide the login form if the user is logged in.
  13. Oh really? Im a little confused as it is working fine without.
  14. I have connected to a database on another page. Everything works fine before i move the form into the php code i just would like the form to disappear once the user is logged in.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.