Jump to content

Best way to handle sorting


skyer2000

Recommended Posts

Right now i'm trying to figure out a good way to have a single php file handle many different types of sorting.

 

For example, sometimes from _GET the page will display by category and by user. Other times, it may just be by user, or other times when there is no _GET, it displays everything.

 

The thing I can't think of is how the query can handle these multiple WHERE clauses, even when the clauses may not exist at certain times the page is pulled up.

 

 

I tried something like the following: WHERE $category, $user. However, when $user is null, it breaks because of the extra comma.

 

If the explanation is long, can someone point me to a good resource on doing this?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/42018-best-way-to-handle-sorting/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.