MumbleVoice-Jen
22-07-2009, 03:23
Hello,
I am having a problem I am hoping someone can help. I have used the below code before and had it working with no issues. However my issue right now is the below foreach loop is only inserting the first record into the mysql table and not all the values in the array. I have confirmed the two array has more then one value in them. Yes only the virst value from each array is being interested into mysql.
here is my form
<form method='POST' action='process.php'>
shift <input type='hidden' name='shiftid[]' value='$shiftid'><br />
Your Rank <select name='shiftrank[]'><option value='1'>1</option><option value='2'>2</option>
foreach($_POST["shiftid"] AS $key => $val) {
$shiftid = $val;
$shiftrank = $_POST['shiftrank'][$key];
echo "shiftid is $shiftid and rank is $shiftrank<br />";
//$updatesql = mysql_query("INSERT into employee_shiftbids SET Shiftid='$shiftid', Shiftrank='$shiftrank', Bidstatus='sent', Employeerank='0'");
}
Also I know I should be using mysql_escape_string() on my $_POST data I took it out during trouble shooting so no need to point out about sql injection etc. So what is wrong with ym foreach loop ??
Thanks all for youre time and assistance
I am having a problem I am hoping someone can help. I have used the below code before and had it working with no issues. However my issue right now is the below foreach loop is only inserting the first record into the mysql table and not all the values in the array. I have confirmed the two array has more then one value in them. Yes only the virst value from each array is being interested into mysql.
here is my form
<form method='POST' action='process.php'>
shift <input type='hidden' name='shiftid[]' value='$shiftid'><br />
Your Rank <select name='shiftrank[]'><option value='1'>1</option><option value='2'>2</option>
foreach($_POST["shiftid"] AS $key => $val) {
$shiftid = $val;
$shiftrank = $_POST['shiftrank'][$key];
echo "shiftid is $shiftid and rank is $shiftrank<br />";
//$updatesql = mysql_query("INSERT into employee_shiftbids SET Shiftid='$shiftid', Shiftrank='$shiftrank', Bidstatus='sent', Employeerank='0'");
}
Also I know I should be using mysql_escape_string() on my $_POST data I took it out during trouble shooting so no need to point out about sql injection etc. So what is wrong with ym foreach loop ??
Thanks all for youre time and assistance