php - Inserting multiple row records using mysqli bind_param? -


i have code here works using mysql query.

$n = count($fullname); for($i=0; $i < $n; $i++)     mysql_query("insert famcomp(fullname,fage,frel,fcivil,fedu,foccup,finco,app_id) values ('$fullname[$i]','$fage[$i]','$frel[$i]','$fcivil[$i]','$fedu[$i]','$foccup[$i]','$finco[$i]','$id')"); 

how convert mysqli bind_param here's did: (i have connection.php (mysqli))

$n = count($fullname); for($i=0; $i < $n; $i++)     $stmt = $conn->prepare("insert famcomp(fullname,fage,frel,fcivil,fedu,foccup,finco,app_id) values (?,?,?,?,?,?,?,?)");     $stmt ->bind_param("ssssssss",$fullname[$i],$fage[$i],$frel[$i],$fcivil[$i],$fedu[$i],$foccup[$i],$finco[$i],$id); } 

but still not getting data.

with code:

$n = count($fullname); for($i=0; $i < $n; $i++)     $stmt = $conn->prepare("insert famcomp(fullname,fage,frel,fcivil,fedu,foccup,finco,app_id) values (?,?,?,?,?,?,?,?)");     $stmt ->bind_param("ssssssss",$fullname[$i],$fage[$i],$frel[$i],$fcivil[$i],$fedu[$i],$foccup[$i],$finco[$i],$id); } 

you bind_params , that's all. statement should executed. can executed several times 1 call prepare:

$n = count($fullname); $stmt = $conn->prepare("insert famcomp(fullname,fage,frel,fcivil,fedu,foccup,finco,app_id) values (?,?,?,?,?,?,?,?)"); for($i=0; $i < $n; $i++)     $stmt ->bind_param("ssssssss",$fullname[$i],$fage[$i],$frel[$i],$fcivil[$i],$fedu[$i],$foccup[$i],$finco[$i],$id);     $stmt->execute(); } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -