Am I able or how can I create a while loop to run through some insert statemtns. I have some code below that I have tried to use using i++ but I keep getting errors in relation to where I have put $i such as:
Object of class PDOStatement could not be converted to string
Its hard to explain the previous code that amounts to this insert setup, but basically I decalre some variables and then they get bind and inserted with the following code but I have like 30 thins that could be inserted hence the while loop. So the outcome should be supplier_name2 - supplier_name30 and same for address etc etc.
while ($i <= 30):
//LINE TWO
$suppliername = $this->supplier_name.$i;
if(!empty($suppliername)){
$sql0.$i = "INSERT INTO suppliers (supplier_name, supplier_address)
VALUES (:supplier_name.$i, :supplier_address.$i) ";
$st0.$i = $conn->prepare ( $sql0.$i );
$st0.$i->bindValue( ":supplier_name".$i, $this->supplier_name.$i, PDO::PARAM_STR );
$st0.$i->bindValue( ":supplier_address".$i, $this->supplier_address.$i, PDO::PARAM_STR);
$st0.$i->execute();
$this->id = $conn->lastInsertId();
$supplierid.$i = $this->id = $conn->lastInsertId();
}
$i++;
endwhile;
Any help appreciated. Ian