Iam trying to fetch related articles for a blog based project Query : $query = mysqli_query($con, “SELECT * FROM posts WHERE cat_id like ‘%$cat_arr[i]%’ AND NOT post_id = ‘$postid'”); …
Tag: sql-like
LIKE query using multiple keywords from search field using PDO prepared statement
Site users use a search form to query a database of products. The keywords entered search the titles for the products in the database. The search works if a user enters a single keyword, but if multiple keywords are used the query does not execute. if: $keywords = ‘apple ipod’; $search = ‘%apple% AND itemTitle LIKE %ipod%’; So the prepared
How to make “LIKE” query work in MongoDB?
I have a list of street names and I want to select all that start with “Al”. In my MySQL I would do something like How about MongoDB using PHP? Answer Use a regular expression: or: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-RegularExpressions Turning this into PHP:
Combine PHP prepared statments with LIKE
Anyone know how to combine PHP prepared statements with LIKE? i.e. “SELECT * FROM table WHERE name LIKE %?%”; Answer The % signs need to go in the variable that you assign to the parameter, instead of in the query. I don’t know if you’re using mysqli or PDO, but with PDO it would be something like: For mysqli user