I’m trying to update my database from my form by using multiple rows. I have two pages, my page with the form and the process page. The process.php page goes through and I don’t see any errors, but my database does not update. I’m missing something, just know sure what. Here’s the code for the form:
[code]
Week
Team Number
Points
Week
Team Number
Points
<!--<button type="submit" class="btn btn-default" name="submit">Submit</button>-->
<input name="Submit" type="submit" />
</form>[/code]
Here’s the process.php:
[php]<?php
ini_set(‘display_errors’, ‘On’);
// pdo connection
include(‘includes/database.php’);
// new data
try{
$week = $_POST['week'];
$TeamNumber = $_POST['Team_Number'];
$points = $_POST['Points'];
$sql = 'INSERT INTO week (id,week, Team_Number, Points) VALUES (:id, :week, :Team_Number, :Points)';
// $db_con is pdo connection
$insertTable = $db_con->prepare($sql);
$countArray = count($array);
$i = 0;
while ($i < $countArray) {
$insertTable->bindParam(':week', $_POST['week'], $array[1][$i], PDO::PARAM_STR);
$insertTable->bindParam(':Team_Number',$_POST['Team_Number'], $array[2][$i], PDO::PARAM_STR);
$insertTable->bindParam(':Points',$_POST['Points'], $array[3][$i], PDO::PARAM_STR);
$insertTable->execute($countArray);
return $db_con->lastInsertId('id');
$i++;
}
} catch (PDOException $e) {
echo 'Connection failed: ’ . $e->getMessage();
}
/echo("\n");
\n");/
print_r($_POST);
echo("
[/php]