Jump to content

Recommended Posts

Hi,

I have a database that stores shopper information , and the items they purchased.

I would like PHP to split table value (seperating using the ' ,') then somehow put it back into the select statement. The Scenario below explains it more clearly.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]e.g. Shopper Database

Name - Julie Jones
Items - Banana, Cereal, Bread, Milk

Name - David Ball
Items - Beer, Milk[/quote]

It varies to how many items they have (based on how many they add into the field)

I now want to (say Julie is logged in [but the code needs to be for whoever is logged in]) to list all the shops that have ANY of those ingredients (so not necessarilly all)

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]e.g Superstore Database

Superstore_Name - Tesco
Superstore_Items - Milk, Bread


Superstore_Name - Corner Shop
Superstore_Items - Cereal


Superstore_Name - Saindsburys
Superstore_Items - Coffee[/quote]

So I want to say (Julie being logged in).....

SELECT Superstore_Name FROM Superstore WHERE Superstore_Items LIKE 'Banana' OR Superstore_Items LIKE 'Cereal' OR Superstore_Items LIKE ' OR Superstore_Items LIKE ' 'Bread' OR Superstore_Items LIKE 'Milk'

.........

In other words PHP needs to split the table value (seperating using the ' ,') then somehow put it back into the select statement.

Please can someone help?

Thanks

d
Link to comment
https://forums.phpfreaks.com/topic/10780-expert-php-coding-help-needed/
Share on other sites

ok that would explain how to seperate them,

but what about understanding how many have been seperated? in order to have a count for a loop , which would then insert each seperated item into the sql query. Are they saved as an array?

How would I go about doing this?

Thanks

D
[!--quoteo(post=378423:date=May 30 2006, 07:21 PM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ May 30 2006, 07:21 PM) [snapback]378423[/snapback][/div][div class=\'quotemain\'][!--quotec--]
ok that would explain how to seperate them,

but what about understanding how many have been seperated? in order to have a count for a loop , which would then insert each seperated item into the sql query. Are they saved as an array?

How would I go about doing this?

Thanks

D
[/quote]

Maybe this can help:
[a href=\"http://www.phpfreaks.com/quickcode/Building-a-Dynamic-Form-Select-Menu/2.php\" target=\"_blank\"]http://www.phpfreaks.com/quickcode/Buildin...lect-Menu/2.php[/a]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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