i want select then insert in php code but my code do nothing.

public function deliverOrders($id_d){
    $p=$this->db->prepare("select saldo from admins where name='".$_SESSION['name']."'");
    $orders=$p->fetchAll(PDO::FETCH_OBJ);
    return $orders;
    if ($orders < 1000){
        echo"<script>alert('you deposit less than 1000);</script>";
    }

    else{
    $q=$this->db->prepare("update orders_foods set status=1 where id=?");

    if($q->execute([$id_d])){

echo"<script>window.location.href='index.php?page=orders';
                        alert('berhasil di kirim');</script>";

    }
    else{
        echo"<script>window.location.href='index.php?page=orders';
                        alert('gagal dikirim');</script>";
    }
}

Why are you using PHP for this? Can't you just use anupdate statement with a where clause?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.