activeradio
New Member
- Messages
- 18
- Reaction score
- 0
- Points
- 0
It's another PDO question. It grabs all the details from the previous page, but it cannot update the fields. Without debugging with print_r, I get the following array. Below is the code, and the table on the previous page.
Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => ) Array ( [0] => 00000 [1] => [2] => )
Code:
print_r($username);
print_r($password);
print_r($email);
print_r($type);
print_r($purchased);
print_r($expiry);
Code:
<tbody>
<tr>
<td><input name="checkbox[]" type="checkbox" value="'.$row[0].'"/></td>
<td><input class="id" name="id[]" size="1" value="'.$row[0].'" readonly/></td>
<td><input class="username" name="username[]" value="'.$row[1].'"/></td>
<td><input class="password" name="password[]" type="password" maxlength=40 value="'.$row[2].'"/></td>
<td><input class="email" name="email[]" type="email" value="'.$row[3].'"/></td>
<td><input class="type" name="type[]" maxlength=1 value="'.$row[4].'"/></td>
<td><input class="purchased" name="purchased[]" value="'.$row[5].'"/></td>
<td><input class="expiry" name="expiry[]" maxlength=19 value="'.$row[6].'"/></td>
</tr>
</tbody>
Code:
$result = $db->prepare("UPDATE members SET username=:username, password=:password, email=:email, type=:type, purchased=:purchased, expiry=:expiry WHERE username=:whereusername");
for ($i = 0; $i < count($username); $i++) {
$result->execute(array(':username' => $username[$i], ':whereusername' => $username[$i], ':password' => $password[$i], ':email' => $email[$i], ':type' => $type[$i], ':purchased' => $purchased[$i], ':expiry' => $expiry[$i]));
print_r($result->errorInfo());
}