I have a text field in a mysql database with data like this: 1929, 929, 884, 1001, 2001, 11001, How can I use PHP to update that feild and remove a particular element? (in a mysql update statement) For instance take out "929," in the above example data? I have to be sure only the exact element is taken out. Any ideas? Thanks in advance!
you mean, you will execute that in 2 queries.. why not one update table (select column from table where value = '929') values ('new value'); thats it ^_^
Hmm, I don't think that is it either.... see....all these 1929, 929, 884, 1001, 2001, 11001, are in a column of type TEXT so whole table looks like this +----+-----------+------------+-------------------------------------------+ | id | user | items | timeUpdate | +----+-----------+------------+-------------------------------------------+ | 2 | 626423142 | 1929, 929, 884, 1001, 2001, 11001, | 2008-11-18 23:33:59 | +----+-----------+------------+-------------------------------------------+ Code (markup): "items" column is type TEXT so how do I replace 929 without clobbering 1929 ...or replace any of those elements without clobbering the others and without clobbering any parts of the others? I'm guessing I need to populate an array with all the numbers I need to save from the column then update the column with the new array. Anyone have any idea how I would go about this?
ow.. it thought it is separate columns.. this will deal more on string manipulation heres an example : $vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"); $onlyconsonants = str_replace($vowels, "", "Hello World of PHP"); // Provides: Hll Wrld f PHP
nevermind I figured it out........I used array_push to push a new set elements back into the field. So it works now. Thanks for helping!