英文:
how to call value $_POST['variable+array'] from name that contain array in input type
问题
I am 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 into the 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 you all.
英文:
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.
答案1
得分: 1
假设表单提交到相同的页面,您可以像这样修改您的代码:
<?php
if (isset($_POST['updatehargautama'])) {
$idharga = $_POST['idharga'];
$hargautama = $_POST['hargautama' . $idharga];
// 现在您已经获得了名称为'hargautama<idharga>'的输入字段的值
}
?>
<!-- 您的HTML表单 -->
<form method="post" action="">
<input type="hidden" name="idharga" value="<?php echo $row['idharga']; ?>">
<input type="text" id="hargautama<?php echo $row['idharga']; ?>" name="hargautama<?php echo $row['idharga']; ?>">
<input type="submit" name="updatehargautama" value="Update">
</form>
在这段代码中,我添加了一个名为"idharga"的隐藏输入字段,用于存储$row['idharga']的值。当表单提交时,它将同时发送名称为'hargautama
英文:
Assuming the form is submitted to the same page, you can modify your code like this:
<?php
if (isset($_POST['updatehargautama'])) {
$idharga = $_POST['idharga'];
$hargautama = $_POST['hargautama'.$idharga];
// Now you have the value from the input field with the name 'hargautama<idharga>'
}?>
//Your HTML form
<form method="post" action="">
<input type="hidden" name="idharga" value="<?php echo $row['idharga']; ?>">
<input type="text" id="hargautama<?php echo $row['idharga']; ?>" name="hargautama<?php echo $row['idharga']; ?>">
<input type="submit" name="updatehargautama" value="Update">
</form>
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<idharga>' 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.
答案2
得分: -1
if (isset($_POST['updatehargautama']))
{
$idharga = $_POST['updatehargautama'];
$hargautama = $_POST['hargautama' . $idharga];
}
英文:
if (isset($_POST['updatehargautama']))
{
$idharga = $_POST['updatehargautama'];
$hargautama = $_POST['hargautama' . $idharga];
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论