3. MySQL PHP Search Programming : SQL LIKE Syntax UNION and AS Alias with Filters Tutorial



Script: http://www.developphp.com/video/PHP/SQL-LIKE-Syntax-UNION-and-AS-Alias-with-Filters
Part 3 of MySQL PHP Search Programming Exercises for database driven web sites. Search pages that allow advanced targeting and filtering of information. Learn to build HTML Search Forms and Advanced Search Filters, Various MySQL Search Query Methods, Joined Table Queries Targeting Multiple Tables, Natural Language Full-Text Search Queries and discuss fine tuning your search programming and adjusting search parameters.

source

37 thoughts on “3. MySQL PHP Search Programming : SQL LIKE Syntax UNION and AS Alias with Filters Tutorial”

  1. hi I really like your tutorial, but am having a problem. i have two tables the first table has 3 colums and the second table has 8 i get errors when i try to search on the table with three colums. in the query section i have 8 variables from $row['a'] to $row['h']. please help me thank you.

  2. Hi adam! When i try to search, others would show correctly and some wont show correctly even if theres a record in the database. The word are the same, just confuse why it wont show. My example is Filter: Gender Search: Female, it would show the female and male.. it wont filter

  3. When i try to search i get

    Successful database connection, happy coding!!!
    Warning: mysql_query(): Access denied for user ''@'localhost' (using password: NO) in C:xampphtdocssearchsearch.php on line 22

    Warning: mysql_query(): A link to the server could not be established in C:xampphtdocssearchsearch.php on line 22
    Access denied for user ''@'localhost' (using password: NO)

    but i know the mysql is there because in the connect_to_mysql.php i get Successful database connection, happy coding!!! can you please help me out?

  4. Great tutorial Adam! However, I found out that that there is a typo where it says: " if($count > 1)"; that should be "if($count > 0)". That took me some time to figure out (thank you), but time well spent to get experience! Maybe, you can elaborate on converting MySql code to MySqli?  That would be awesome! Kind regards, F. 

  5. Hi! For some reason, only the words Adam used as examples returned actual results with the code that I copied from his site. Other words like 'disney', 'javascript', 'calculator', etc…return 0 results…how is this possible?

  6. I have added another option to the listbox, advising the user to make a selection. My objective is so that if the end user enters text in the searchbox but does not choose an option from the dropdown then a message will echo out at the top of the form advising them to make a selection from the list as well as enter a search term however I am getting the following message – Undefined variable: sqlCommand in line 22. Wondered if someone could enlighten me.

  7. Hi ur tutorials are excellent here i have a doubt about search i have 4 tables which are linked between each other with relevant ids. my question is how can i search from these tables. tables are products- fields are id, product name, price and details.
    product_categories- fields are id and categories.
    product_subcategories- fields are id and subcategories.
    and product_categories_taken- fields are id, pid(id from products), pcid(from product_categories) , and psid (from product_subcategories).

  8. Great tutorial, just ignore the last 4 minutes of it where he explains that you need to add
    an extra field to your tables and set default values

    The correct and easier way to do this would be to add
    SELECT id, page_title AS title, *** 'pages' as tableName ***WHERE …..
    (don't add the ***) – do the same for 'blog'.

    You can then reference this as if it was a column. ($columnName = $row['tableName'];

    Hope this helps someone.

  9. + if you are planning to support UTF8, this regexp will not match UTF8. You can add p{L} to match UTF8 characters (non-punctuation) and better to replace (space) match with class s , matching all space-like characters like tabs etc.

    Good Luck !

  10. This was the first series of yours I ever watched. Ironically I have not ever had to use search code until now So I revisited this. Got it going great in minutes. Then it took about 3 hours to figure out why some searches were not happening even though the same code worked great in Php MyAdmin. Long story short………..

    if($count > 1 Hmmmmmmmmm Maybe it should be if($count >= 1 Or even if($count > 0 ? Just saying………

  11. Adam, Great tutorial, I just wondering what you mean by saying:
    filter the variable [searchquery] at 07:20 because Sql injection, how I can filter the query?
    I'm currently using the preg_replace like you and mysql_real_scape_stings function, this is okey? if not, how I increase the security to avoid basic sql injections?

    Thanks!

  12. thanks for tutorial.. do you also do this kind of tutorials for asp.net… if you can its will be really great. There is not much information on youtube for asp.net
    thank you Great man!

Leave a Reply

Your email address will not be published. Required fields are marked *