dql123000 2013-07-30 21:20
浏览 13

更新多个字段时更新不推送到数据库

This is the same as my last program but im using much more tables and information but it is the same idea, but when i try running it here, the data does not go through to the database and it reloads the old information instead of the information i tried to send.

<?php
$page = "login";
$title = "LatinSoft - Login";

include "header.php";
include "config.php";


if (isset($_POST['submit']) && $_POST['submit'] == 'Update') {

$updateQuery = ("UPDATE `users` SET email = '$_POST[email]', f_name = '$_POST[f_name]', 
                 l_name = '$_POST[l_name]', m_name = '$_POST[m_name]', phone = '$_POST[phone]', 
                 address = '$_POST[address]', city = '$_POST[city]', state = '$_POST[state]', 
                 zip = '$_POST[zip]', rights = '$_POST[rights]', comp_name = '$_POST[comp_name]', 
                 comp_tel = '$_POST[comp_tel]', comp_add = '$_POST[comp_add]', 
                 comp_city = '$_POST[comp_city]', comp_state = '$_POST[comp_state]', 
               WHERE id = '$_POST[id]'");
//$link defined in config.php
mysqli_query($link, $updateQuery);


};

$query = ("SELECT `ID`, `email`, `f_name`, `l_name`, `m_name`, `phone`, `address`, `city`, `state`, `zip`, `rights`, `comp_name`, `comp_tel`, `comp_add`, `comp_city`, `comp_state` FROM `users`");
$result = mysqli_query($link, $query);

echo "<table width=10%  border=0 cellpadding=0 cellspacing=1>

<tr>
<th>Email</th> 
<th>Firstname</th>
<th>Lastname</th>
<th>Middle Name</th>
<th>Phone</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Rights</th>
<th>Company Name</th>
<th>Company Telephone</th>
<th>Company Address</th>
<th>Company City</th>
<th>Company State</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
?>

<form method="post" action="updateuser.php">
<tr>
<td><input type="text" name="email" value="<?php echo  $row['email']; ?>"></td>
<td><input type="text" name="f_name" value="<?php echo $row['f_name']; ?>" ></td>
<td><input type="text" name="l_name" value="<?php echo $row['l_name']; ?>" ></td>
<td><input type="text" name="m_name" value="<?php echo $row['m_name']; ?>"></td>
<td><input type="text" name="phone" value="<?php echo $row['phone']; ?>" ></td>
<td><input type="text" name="address" value="<?php echo $row['address']; ?>" ></td>
<td><input type="text" name="city" value="<?php echo $row['city']; ?>" ></td>
<td><input type="text" name="state" value="<?php echo $row['state']; ?>" ></td>
<td><input type="text" name="zip" value="<?php echo $row['zip']; ?>" ></td>
<td><input type="text" name="rights" value="<?php echo $row['rights']; ?>" ></td>
<td><input type="text" name="comp_name" value="<?php echo $row['comp_name']; ?>" ></td>
<td><input type="text" name="comp_tel" value="<?php echo $row['comp_tel']; ?>" ></td>
<td><input type="text" name="comp_add" value="<?php echo $row['comp_add']; ?>" ></td>
<td><input type="text" name="comp_city" value="<?php echo $row['comp_city']; ?>" ></td>
<td><input type="text" name="comp_state" value="<?php echo $row['comp_state']; ?>" ></td>
<td><input type="hidden" name="id" value="<?php  echo $row['id'];  ?>"></td>
<td><input type="submit" name="submit" value="Update" ></td>
</tr>
</form>

<?php
}
include "footer.php";
?>
  • 写回答

2条回答 默认 最新

  • dongwen3437 2013-07-30 21:24
    关注

    Look at your update query.

    Remove the , before the WHERE

    $updateQuery = ("UPDATE `users` SET email = '$_POST[email]', f_name = '$_POST[f_name]', 
                 l_name = '$_POST[l_name]', m_name = '$_POST[m_name]', phone = '$_POST[phone]', 
                 address = '$_POST[address]', city = '$_POST[city]', state = '$_POST[state]', 
                 zip = '$_POST[zip]', rights = '$_POST[rights]', comp_name = '$_POST[comp_name]', 
                 comp_tel = '$_POST[comp_tel]', comp_add = '$_POST[comp_add]', 
                 comp_city = '$_POST[comp_city]', comp_state = '$_POST[comp_state]'
               WHERE id = '$_POST[id]'");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算