Filtering entry table data with AJAX

was looking through the forums and found this topic on filtering with AJAX , how would i go about doing this?

The main tutorial is here.

The main issue i am having is when a shoe is in in two categories i.e running and walking

please bear in mind i am not fully normalising these tables to make it easier for data entry purposes , ideally want to filter with commas

shoe_ID 1
shoe_name nike
shoe_color grey,blue,black
shoe_type running,walking
The closest i have gotten so far is with this query

SELECT * FROM shoes WHERE CONCAT(type,‘,’) LIKE ‘%walking,%’ AND OR ‘%running,%’
The only problem i can forsee if that if the check boxes are not ticked in order

The original tutorial is in PDO and i need to figure out how to do this in mysql and sql

Cramming multiple values into a single column using a delimiter is a terrible way of doing things and completely defeats the purpose of a relational database in the first place.

However, putting that and scalability/performance aside you would use FIND_IN_SET.

Unless you inherited that code from someone else and/or are dealing with CMS restrictions you should be doing things the proper way or not all. Otherwise several people in the future are going to pay for that poor architectural decision ranging from your client when scalability becomes a concern to a developer when a feature enhancement is necessary.

I dont want lots and lots of tables to have to refer to

I don’t understand what you mean. All you need is two separate tables for color and type. Also it isn’t about what you want but what is best for the problem taking into account scalability and maintainability. Unless you’re working within other constraints storing atomic data in a single column is a hard and fast no – db architecture 101.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.