020 555 1111
  • Old fashion, modular, procedural PHP plus some scaffolding techniques to allow it to mimic MVC simplicity.
  • A quick reference to help you find in PHP maze what needs to be done and how to do it.
  • Learn a PHP Object Oriented Programming by building a live discussion forum application.
  • MVC - Model View Controller - real life, easy reference and application.
This product has options, take a look at them and select ones you like the most.
Options are displayed under image section.

Prepared statement loop insert.
[MySQL example]

way 1:

$stmt = $mysqli->stmt_init();
//prepare actual statement template
if ($stmt->prepare("SELECT name FROM at WHERE code LIKE ?")) {
    $var = "%shire";
    $stmt->bind_param("s", $var);
    $stmt->execute();
    $stmt->bind_result($name);
    $stmt->store_result();
    while ($stmt->fetch()){
        echo $name;
        $mysqli->query("INSERT INTO atmp (name) VALUES ('".$name."')");
        $mysqli->commit();
    }
   
}
$stmt->close;

 

way 2:

$stmt = $mysqli->stmt_init();
//prepare actual statement template
if ($stmt->prepare("SELECT name FROM at WHERE code LIKE ?")) {
    $var = "%shire";
    $stmt->bind_param("s", $var);
    $stmt->execute();
    $stmt->bind_result($name);
    $stmt->store_result();
    
}
$stmt->close;
   
while ($stmt->fetch()){
   $stmt1 = $mysqli->stmt_init();
    
    if ($stmt1->prepare("INSERT INTO atmp (name) VALUES (?)")) {
        $stmt1->bind_param("s", $name);
        $stmt1->execute();
    }
      
}
$stmt1->close;  

way 3:

//initiate statement
$stmt = $mysqli->stmt_init();
//prepare sql tmplate
if ($stmt->prepare("UPDATE users SET type = ? WHERE user_id = ?")) {
    
    //bind params to sql template
    $stmt->bind_param("ii",$t,$u);
    
    //loop sql template params
    //only one binding is necessary for as many sets of params as required for the task
    if (is_array($type_array)) {  
        foreach ($type_array as $user_id => $type) {     
            $t = $type;
            $u = $user_id;
            $stmt->execute();
        }   
    }
}
//close statement
$stmt->close;