I got uncaught error in that line because I don't know what to put into the while() statement. I just want to make sure the syntax can display the data.
<?php   
require_once 'core.php';
    $valid['success'] = array('success' => false, 'messages' => array(), 'order_id' => '');
    if($_POST) {    
        $orderDate     = date('Y-m-d', strtotime($_POST['orderDate'])); 
        $clientName    = $_POST['clientName'];
        $sql = "INSERT INTO orders (order_date, client_name, order_status) VALUES ('$orderDate', '$clientName', 1)";
        $order_id;
        $orderStatus = false;
        if($connect->query($sql) === true) {
            $order_id = $connect->insert_id;
            $valid['order_id'] = $order_id; 
            $orderStatus = true;
        }
            // echo $_POST['productName'];
        $orderItemStatus = false;
        for($x = 0; $x < count($_POST['namaBahan']); $x++) {            
            while ($sql->fetch_row()) {
                    // add into order_item
                    $orderItemSql = "INSERT INTO order_item (order_id, id_bahan, kuantiti, jenis_kuantiti, harga_per_unit, jumlah, order_item_status) 
                    VALUES ('$order_id', '".$_POST['namaBahan'][$x]."', '".$_POST['kuantiti'][$x]."', '".$_POST['jenisKuantiti'][$x]."','".$_POST['harga'][$x]."', '".$_POST['jumlahValue'][$x]."', 1)";
                    $connect->query($orderItemSql);     
                    if($x == count($_POST['namaBahan'])) {
                        $orderItemStatus = true;
                    }       
            } // while  
        } // /for quantity
        $connect->query($orderItemSql);
        $valid['success'] = true;
        $valid['messages'] = "Successfully Added";      
        $connect->close();
        echo json_encode($valid);
    }
Can somebody help me to solve that statement in that line?
Fatal error: Uncaught Error: Call to a member function fetch_row() on string in C:\xampp\htdocs\inventori\php_action\createOrder.php:27 Stack trace: #0 {main} thrown in C:\xampp\htdocs\inventori\php_action\createOrder.php on line 27
 
    