please i submitted a form and was trying to use the values.
when i use
print_r($_POST);
it comes back with theses values
Array ( [item] => Array ( [0] => Array ( [Pquantity] => 1 [Pidno] => 1 ) ) )
then assigned to $items
if(array_key_exists('item', $_POST)){
$items = $_POST['item'];
ow can i verify the values
i tried this
echo $items['item'][Pquantity];
it comes back with nothing
<?php
foreach($_POST['item'] as $item){
echo $item['Pquantity'];
}
@AnthonySterling that works, please when i try to update, it dosent, can you help look at this code
(the value in the POST array, is the updated values on the form)
Array ( [item] => Array ( [0] => Array ( [Pquantity] => 5 [Pidno] => 2 ) [1] => Array ( [Pquantity] => 6 [Pidno] => 1 ) ) )
//print_r($_POST);
if(array_key_exists('item', $_POST)){
//$items = $_POST['item'];
//foreach($_POST['item'] as $item){
//echo $item['Pquantity'] . ", ";
//echo $item['Pidno'] . ", ";
//}
//Loop through $_POST items, updating the database for each item
foreach ($_POST['item'] as $item) {
$Pquantity = intval($item[0]);
$Pidno = intval($item[1]);
$queryreg = mysql_query("
UPDATE repplac
SET Pquantity = {$Pquantity}
WHERE
Pidno = {$Pidno}
AND
username = '{$_SESSION['username']}'
"
You’re using numeric indicies for the $item array, you should be using Pquantity, Pidno etc; the numeric ones do not exist.
its updating now, i used
//print_r($_POST);
if(array_key_exists('item', $_POST)){
// $items = $_POST['item'];
//foreach($_POST['item'] as $item){
//echo $item['Pquantity'] . ", ";
//echo $item['Pidno'] . ", ";
// }
//Loop through $_POST items, updating the database for each item
foreach ($_POST['item'] as $item) {
$Pquantity = intval($item['Pquantity']);
$Pidno = ($item['Pidno']);
//echo $Pquantity . ", ";
//echo $Pidno . ", ";
$queryreg = mysql_query("
UPDATE repplac
SET Pquantity = {$Pquantity}
WHERE
Pidno = {$Pidno}
AND
Uname = '{$_SESSION['username']}'
") or die(mysql_error());