dtpngq3378499 2014-07-29 07:41
浏览 58
已采纳

如果我有不同的ID,如何更新MySQL数据库?

I have a problem when trying to UPDATE MySQL database. I'll write the code below.

The problem is that, I have some reviews/feedbacks from my application, and I'm trying to edit a comment from one of them. I'll put the code here:

HTML CODE

<input type="text" size="70" 
id="edit<?php echo $row['id'];?>" 
name="edit" 
style="display: none;">

<input type="image" 
name="save" 
id="save<?php echo $row['id'];?>" 
value="<?php echo $row['id'];?>" 
onclick="ask_confirm('Are you sure you want to edit the comment?','save<?php echo $row['id']; ?>')" style="display: none;" src="png/accept.png" />

PHP CODE

if(isset($_POST['save']) && isset($_POST['edit'])){
    $edit = $_POST['edit'];
    foreach($_POST['save'] as $here)
         mysqli_query($con,"UPDATE feedback_rate SET comment = ".$edit." WHERE id = $here");
}

And when I print_r($_POST), it shows me this:

Array (
    [edit] => 
    [save_x] => 8
    [save_y] => 9
    [save] => 48
)

It doesn't take the [edit] POST. Any help would be great! Thanks guys!

  • 写回答

2条回答 默认 最新

  • dragon202076 2014-07-29 07:43
    关注

    The input edit doesn't have a value. You should put a value to the value property in order to get anything in the POST, like this:

    <input type="text" size="70" 
        value="edit<?php echo $row['id'];?>" 
        name="edit" 
        style="display: none;">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度