iam a newbie, i have a problem with this code, please help.
<input type="text" id="hargautama<?php echo $row['idharga']; ?>" name="hargautama<?php echo $row['idharga']; ?>">
my problem is on this
if(isset($_POST['updatehargautama'])){
$hargautama = $_POST['????'];
i want to insert this value to database from this input type
<input type="text" id="hargautama<?php echo $row['idharga']; ?>" name="hargautama<?php echo $row['idharga']; ?>">
thanks for the help guys. i owe u all.
2
Answers
Assuming the form is submitted to the same page, you can modify your code like this:
In this code, I’ve added a hidden input field named "idharga" to store the value of $row[‘idharga’]. When the form is submitted, it will send both the value from the input field with the name ‘hargautama’ and the ‘idharga’ value in the $_POST array. then access the ‘idharga’ value to construct the correct name of the input field and retrieve the corresponding value.