I am trying to update my table column but I keep getting one value for all the rows, what am I doing wrong?
<?php
$count = 1;
while ( $count <= 30) {
$fmle_img = "_src/img/profile/female/u$count.png";
$db->query("UPDATE users SET image=:image WHERE (id > 31 AND id < 62)", array(':image'=>$fmle_img));
$count ++;
}
// this keeps giving me _src/img/profile/female/30.png for all the rows between id 32 and id 61
?>
>Solution :
You must vary the where condition for each image:
<?php
$count = 1;
while ( $count <= 30) {
$id = $count + 32;
$fmle_img = "_src/img/profile/female/u$count.png";
$db->query('UPDATE users SET image = :image WHERE id = :id', array(':image'=>$fmle_img, ':id' => $id));
$count ++;
}