creating sql statement from an exploded array
Posted: Wed Aug 27, 2008 4:48 pm
tblFruits
Fruits (column)
-------
John 1, 3, 4
Mary 2,3
tblFruitDetail
id Description
---------------
1 Apple
2 Banana
3 Guava
4 Grapes
ok... i can explode the value from tblFruits
But how can I generate an SQL statement to pass it on a string variable that would display the Description:
Ex:
John's Basket -
Apple
Banana
Grapes
Mary's Basket -
Banana
Guava
I would appreciate any response. Thanks!
Fruits (column)
-------
John 1, 3, 4
Mary 2,3
tblFruitDetail
id Description
---------------
1 Apple
2 Banana
3 Guava
4 Grapes
ok... i can explode the value from tblFruits
Code: Select all
$someWords = $return[Fruits]; (generated SQL statement from tblFruits)
$wordChunks = explode(", ", $someWords);
for($i = 0; $i < count($wordChunks); $i++)
{
echo "$wordChunks[$i] <br />";
}
Ex:
John's Basket -
Apple
Banana
Grapes
Mary's Basket -
Banana
Guava
I would appreciate any response. Thanks!