N
N
Nikita Kochetkov2016-11-06 23:20:23
PHP
Nikita Kochetkov, 2016-11-06 23:20:23

How to add data to a db cell?

There is a pending cell, by clicking on different buttons, some data should be added to the cell.
There is a code:

$r = $connection->query("SELECT pending FROM personal_data WHERE connect_id = '$userlogin'");
    while($row2 = $r->fetch()){
        $kastinglist = $row['pending'];
        echo $kastinglist;
    }
      
    try{
        $kastinglist = $kastinglist . ',' . $_POST['id'];
        $stmt = $connection->prepare("UPDATE personal_data SET 
        pending = :pending
        WHERE connect_id = '$userlogin'");
        $stmt->execute(array(
            ':pending' =>  $kastinglist     
        ));
        echo $kastinglist;
        ?> Анкета пользователя <?php echo $userlogin ?> обновлена <?php
            
    }catch(PDOException $e){
         echo 'ERROR:' . $e->getMessage();
    }

When clicked, the cell is overwritten with the data of the last button, what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2016-11-06
@fiercekilla

and than you did not please concat?

update personal_data set pending = concat(pending,'$kastinglist') where connect_id = '$userlogin'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question