feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks for your replies guys!!!
OK, what I mean by string is literally a jpg filename (pic_name_123.jpg) <-something like thi every time
or
they can use strickly a number (123 or 687 or 984 etc etc) the id number
Could be ONLY these two scenarios
Now, to search for numbers (id number), it has to be in a specific field inside the database table and to search for a string (filename) has to be in a different specific field in the table
So my idea is to perform a different query depending on the input
Here is the actual mysql query...
For strings (filename) case:
[syntax="sql"]select p.products_id, p.products_model, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and [b]p.products_image[/b] like '%" . tep_db_input($search) . "%' order by p.products_model
For numbers (id number) case:
Code: Select all
select p.products_id, p.products_model, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and [b]p.products_model[/b] like '%" . tep_db_input($search) . "%' order by p.products_model
In bold are the differece in the two queries, so unless there is a way to merge them together, i guess the if else idea for numbers or strings should work
So which is the proper way to handle this issue?
Thanks for your quick replies. I like these forums!!!
feyd | Please use[/syntax]Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]