I'm trying to update multiple row/rows in my form. I'm getting the error Notice: Array to string conversion in C:\wamp.....
I'm also getting another error Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\....
Both of these are now fixed.
Form
$ad = "<form action='updaterecords.php' method='post' id='update'> \n";
$records = $this->query_recs();
foreach ($records as $record) {
$ad .= "<p id='id{$record->id}'>";
$ad .= "<input type='hidden' name='id[]' value='" .$this->render_i18n_data($record->id) . "' />\n";
$ad .= "<input type='text' name='paname[]' value='". $this->render_i18n_data($record->pa_name) . "' class='paname' />\n";
$ad .= "<input type='text' name='pcname[]' value='". $this->render_i18n_data($record->pc_name) . "' class='pcname' />\n";
$ad .= "<input type='text' name='pdname[]' value='". $this->render_i18n_data($record->pd_name) . "' class='pdname' />\n";
$ad .= "<input type='text' name='pfname[]' value='". $this->render_i18n_data($record->pf_name) . "' class='pfname' />\n";
$ad .= "<input type='submit' name='update' value='Update' />";
$ad .= "</p>";
}
echo($ad);
PHP
<?php
include 'dbdetails.php';
$con = new mysqli($server, $user, $pass, $db);
// Check connection
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
echo "Connected successfully";
if(isset($_POST['update'])){
$id = $_POST['id'];
$paname = $_POST['paname'];
$pcname = $_POST['pcname'];
$pdname = $_POST['pdname'];
$pfname = $_POST['pfname'];
mysqli_query($con, "UPDATE wp_pbcbc_records
SET pa_name = '$paname', pc_name='$pcname', pd_name='$pdname', pf_name='$pfname'
WHERE id = '$id' ");
header("location: localhost/myp");
exit;
}
?>
Update: This has now been solved. Thanks to the people who gave me an answer!