Search code examples
phpsqlsql-delete

Delete single item in SQL array PHP


This has been driving me crazy: If I have an entry in a SQL db as such: [1,2,3,4]

How can I delete a single item in the array?

mysqli_query = ("DELETE FROM table WHERE id='$id'... (something to specify the item here)");??

Solution

  • This should do it, adjust it as needed of course.

    $string = cell date to here;
    
    $new_string = str_replace('replace', 'with', $string);
    
    echo "{$string}<br>{$new_string}";
    
    // commented until new strings visually compared.
    #mysqli_query("update table set `items` = {$new_string} WHERE `id` = {$id}");
    

    I prefer to use braces around variables, its just a preference and i dont normally use html inside php but for a single break line it seems pointless to skip out and back into php.