Update sql table based on keys/subkeys of array

Hi,
I’ve made a little web app that send email based on array
In this case the email is sended at email@email.it with all the details contained into the array, my problem is this:

When the email is sended i want to update the db based on the id contained in the array but i’m stuck on it because he update me only the last value
( in this case he update only the ID 14)

i use this code:

} else {
        echo 'Message has been sent';
    $sql="UPDATE news SET STATUS='S'  WHERE ID='".$item['0']."'";

Array:

 Array
(
    [0] => Array
        (
            [0] => 49
            [1] => sd
            [2] => ds
            [3] => ds
            [4] => 2015-01-20
            [5] => mail@mail.it
        )

    [1] => Array
        (
            [0] => 8
            [1] => Test
            [2] => 187
            [3] => 000000
            [4] => 2015-01-21
            [5] => mail@mail.it
        )

    [2] => Array
        (
            [0] => 14
            [1] => Test
            [2] => 5500
            [3] => 555555
            [4] => 2015-01-17
            [5] => mail@mail
        )

)

Perhaps a hint will help.

Thanks.
But in my situation i dont’ know how many array keys the system will put out.

If in my table there are two rows with the same email the system will send one email (array with multiple keys)
if there is one rows (array with one keys)

So when i have to update the db my script is updating only the last item of the array (in this case ID 14)
I was wondering if there is a cicle or count to do.

[FPHP]foreach[/FPHP]
[FPHP]implode[/FPHP]

Though if you arnt already looping, your problllem isnt that it is only updating the last value, it’s that it’s sending the last message in the queue… without seeing the rest of your code, s’the best advice i can offer.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.