Hi
I have a code on a site that i need to update . Its quite old.
I have to select multiple records and then update the "Type" field in the selections.
The records get listed but this
I can't fathom what could be going wrong but there is some issue in the array i think?
Would greatly appreciate some help.
Thanks
anandis
I have a code on a site that i need to update . Its quite old.
I have to select multiple records and then update the "Type" field in the selections.
The records get listed but this
<input type=text name=type[] size=25 value=\"$type\">
doesn't get changed. I can't fathom what could be going wrong but there is some issue in the array i think?
Would greatly appreciate some help.
Thanks
anandis
PHP:
<?php
include ("head.php"); //db info for DB2
include ("incv.php"); //db info for DB2
if (!isset($_SESSION['userid'])) {
echo "<center><font face='Calibri' size='2' color=red>Sorry, Please login and use this page </font></center>";
exit;
}
$userid = $_SESSION['userid'];
$ocid = $_POST["ocid"];
$ocid = filter_input(INPUT_GET, 'ocid', FILTER_SANITIZE_STRING);
$sqlS1 = " SELECT * FROM TableST WHERE OCID = '$ocid' ";
//echo $sqlS1;
$resultS1 = mysqli_query($link2, $sqlS1);
$numofrows = mysqli_num_rows($resultS1);
echo "<table border='1' style='border-collapse: collapse' bordercolor='#111111' width='100%'>\n";
echo "<tr bgcolor='#ECF2F8'>
<td><font size=2 face=Calibri color=black><b>S.ID</td>
<td><font size=2 face=Calibri color=black><b>Despatch ID</td>
<td><font size=2 face=Calibri color=black><b>Invoice No.</td>
<td><font size=2 face=Calibri color=black><b>Type</td>
\n";
for ($i = 0; $i < $numofrows; $i++) {
$myrowS1 = mysqli_fetch_array($resultS1);
$shipid = $myrowS1["SHIPID"];
$invno = $myrowS1["Invno"];
$type = $myrowS1["Type"]; // This value is the one to be updated or modified and varies for every record
if ($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"D0D8E0\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"white\">\n";
}
printf("<td><input type=\"checkbox\" name=\"despatch[]\"value=$shipid></TD>
<td><input name=\"shipid\" type=\"text\" id=\"shipid\" size=\"12\" value=" .$shipid. "></TD>
<td><input type=text name=invno size=12 value=\"$invno\"></TD>
<td><input type=text name=type[] size=25 value=\"$type\"></TD>
");
echo "</TR>\n";
}
echo "</TABLE>\n";
echo " <input type='submit' value='Update' name = 'submit'>\n";
?>
<input type="hidden" name="userid" value="<? echo $userid ?>" >
<input type="hidden" name="ocid" value="<? echo $ocid ?>" >
</form>
<?
if(isset($_POST['Update'])) {
$shipid_array = $_POST["shipid"];
$type_array= $_POST["type"];
$invno_array= $_POST["invno"];
$despatch_array = $_POST["despatch"];
if($despatch_array){
foreach ( $despatch_array as $key => $value)
{
$invno = $invno_array[$key];
$type = $type_array[$key];
$SQL2 = " UPDATE `TableST` SET `Type` = '{$type}' , Invno = '{$invno}' WHERE `SHIPID`= '{$value}' ";
$result2 = mysqli_query($link2, $SQL2) or die (mysqli_errorno()) ;
?>