【问题标题】:I want to update the data with php我想用 php 更新数据
【发布时间】:2019-04-08 06:20:38
【问题描述】:

我想用 PHP 更新数据。当我单击按钮时,页面刷新并且没有发生更新。如何纠正

我的代码: 文件名:Contact_settings

<form action="../netting/islem.php"  method="post" class="form-horizontal form-label-left">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Gsm Number<span class="required">*</span></label>
    <div class="col-md-6 col-sm-6 col-xs-12">
        <input type="text"  name="ayar_tel"  value="<?php echo $ayarcek['ayar_tel'] ?>" required="required" class="form-control col-md-7 col-xs-12">
    </div>

<div class="form-group">
 <div align="right" class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
    <button type="submit" name="iletisim" class="btn btn-success right">Güncelle</button>
 </div>
  </div>

文件名:islem.php

if(isset($_POST['iletisim'])){

$ayarkaydet = $db->prepare("UPDATE ayar SET
      ayar_tel       =:ayar_tel,
      WHERE ayar_id=3
  ");
$update = $ayarkaydet->execute
(
    array(
        ':ayar_tel'       => $_POST['ayar_tel'],

    )
);

【问题讨论】:

  • 投票为拼写错误:ayar_tel,

标签: php html database pdo


【解决方案1】:

你的代码有错误

一定是这样的

if(isset($_POST['iletisim'])){

    $ayarkaydet = $db->prepare("UPDATE ayar SET ayar_tel =:ayar_tel WHERE ayar_id=3  ");
    $update = $ayarkaydet->execute (array(':ayar_tel' => $_POST['ayar_tel']));
}

我在你的 sql where 和你的执行数组中删除两个逗号,并为 if 语句添加一个关闭 }。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 2022-01-19
    • 1970-01-01
    • 2018-02-11
    • 2019-05-20
    • 2015-07-16
    • 2019-10-24
    相关资源
    最近更新 更多