Okay, I am making a trading script for my site. My site is a virtual site, you can have virtual items and now you can trade them. Each item has an id as well as a name. You get to choose what items you want to trade and then it combines what you choose, converts the names of the item(s) into the item ids and puts it into an array then puts it in a db. i did this with foreach and join, as shown below. ($bartitem was a form field named bartitem[]).
$comma = array();
foreach ($bartitem AS $value) {
array_push($comma,$value);
}
$comma2 = join(",",$comma);
echo "Success!";
So everything is peachy, I made it so you can view the latest trades by splitting it then using the foreach function again. But then I decided to make it so users can search by the item name. So I first converted the item name they typed in and converted it into item id. I then did a select * from table WHERE itemsid LIKE $id.
So I thought everything worked fine. But then lets say you search for an item that has an id of 4. It will bring back items with any number 4, like 14, 24, etc.
Now you're probably thinking just change the like to =. But you can't forget that the column itemids is an array and more often than not it will have more than one item in it, such as 14,16,17,27, etc.
Help please 🙂