I want to know how to update a database by editing of retrieval through populated drop down menu.after searching a lot it could not work.so please help me.
Code:
<?php
while($row1 = @mysql_fetch_array($aCustomer,MYSQL_ASSOC))
{
echo " head <input type='text' name='head' value='".$row1['head']."'><br/><br/>";
echo " description <input type='text' name='description' value='".$row1['description']."'><br/><br/>";
echo " file no <input type='varchar' name='fileno' value='".$row1['fileno']."'><br/><br/>";
echo " Name of firm <input type='text' name='Nameoffirm' value='".$row1['Nameoffirm']."'><br/><br/>";
echo " exp <input type='int' name='exp' value='".$row1['exp']."'><br/><br/>";
echo " date of sanction <input type='date' name='dateofsanction' value='".$row1['dateofsanction']."'><br/><br/>";
echo " date of po <input type='date' name='dateofpo' value='".$row1['dateofpo']."'><br/><br/>";
echo " date of indent <input type='date' name='dateofindent' value='".$row1['dateofindent']."'><br/><br/>";
echo " bill no <input type='int' name='billno' value='".$row1['billno']."'><br/><br/>";
echo " date of bill no <input type='date' name='dateofbillno' value='".$row1['dateofbillno']."'><br/><br/>";
echo " BLno <input type='int' name='BLno' value='".$row1['BLno']."'><br/><br/>";
echo " bill pass <input type='varchar' name='billpass' value='".$row1['billpass']."'><br/><br/>";
echo " bill amount <input type='int' name='billamt' value='".$row1['billamt']."'><br/><br/>";
echo " date of bill <input type='date' name='dateofbill' value='".$row1['dateofbill']."'><br/><br/>";
echo " available bal <input type='int' name='availbal' value='".$row1['availbal']."'><br/><br/>";
echo " progressive bal <input type='int' name='progbal' value='".$row1['progbal']."'><br/><br/>";
echo " remark <input type='varchar' name='remark' value='".$row1['remark']."'><br/><br/>";
$head = $row1['head'];
$description = $row1['description'];
$fileno = $row1['fileno'];
$Nameoffirm = $row1['Nameoffirm'];
$exp = $row1['exp'];
$dateofsanction = $row1['dateofsanction'];
$dateofpo = $row1['dateofpo'];
$indentno = $row1['indentno'];
$dateofindent = $row1['dateofindent'];
$billno = $row1['billno'];
$dateofbillno = $row1['dateofbillno'];
$BLno = $row1['BLno'];
$billpass = $row1['billpass'];
$billamt = $row1['billamt'];
$dateofbill = $row1['dateofbill'];
$availbal = $row1['availbal'];
$progbal = $row1['progbal'];
$remark = $row1['remark'];
?>
<?php } ?>
</table>
</td>
</tr>
<?php } ?>
<form method="post">
<?php
if(isset($_POST['update']))
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = "purchase";
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname) or die(mysql_error());
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$qry_result= mysql_query("SELECT RCtotal FROM nfcurrent") or die(mysql_error());
$row=mysql_fetch_array($qry_result);
$num=$row[RCtotal];
$description2 = $_POST['description'];
$fileno2=$_POST['fileno'];
$indentno2 = $_POST['indentno'];
$dateofindent2=$_POST['dateofindent'];
$billno2 = $_POST['billno'];
$dateofbillno=$_POST['dateofbillno'];;
$BLno2 = $_POST['BLno'];
$billpass2 = $_POST['billpass'];
$billamt2 = $_POST['billamt'];
$dateofbill2=$_POST['dateofbill'];
$remark2 = $_POST['remark'];
$availbal=$num;
$progbal=$num-$billamt;
$sql = "UPDATE nfone
SET indentno ='$indentno2',
dateofindent = '$dateofindent2',
billno = '$billno2',
dateofbillno = '$dateofbillno2',
BLno = '$BLno2',
billpass = '$billpass2',
billamt = '$billamt2',
dateofbill = '$dateofbill2',
availbal = '$num',
progbal = '$progbal'
WHERE fileno = '$fileno'";
mysql_select_db('purchase');
$retval = mysql_query( $sql, $conn );
$RC=$progbal;
$sqla = "UPDATE nfcurrent
SET RCtotal = '$progbal'";
$retvala = mysql_query( $sqla);
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($conn);
}
else
?>
<input name="update" type="submit" id="update" value="Update">
</form>
</table>
</form>
</body>
</html>