我尝试上传多行时出错

时间:2016-08-28 18:40:21

标签: php mysql sql

我有两个页面第一个select.php显示4个记录,当我可以修改每个中的一个值,但当我尝试修改并转到第二页upload.php时出现错误。

我在php我的管理员中尝试更新,它可以正常工作

查询错误:

UPDATE lc_t_configuracion SET valor = '11:12' WHERE id_conf =6 LIMIT 1

select.php

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_admin = "localhost";
$database_admin = "xxx";
$username_admin = "xxx";
$password_admin = "xxx";
$admin = mysql_pconnect($hostname_admin, $username_admin, $password_admin)     or trigger_error(mysql_error(),E_USER_ERROR); 

mysql_select_db("xxx") or die("Unable to select database");


$sql = "SELECT * FROM lc_t_configuracion where id_conf between 6 and 9 ORDER BY id_conf";

$result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());

$i = 0;

echo '<table width="50%">';
echo '<tr>';
echo '<td>ID</td>';
echo '<td>Concepto</td>';
echo '<td>Valor</td>';
echo '</tr>';

echo "<form name='form_update' method='post' action='update.php'>\n";
while ($lc_t_configuracion = mysql_fetch_array($result)) {
echo '<tr>';
echo "<td>{$lc_t_configuracion['id_conf']}<input type='hidden'     name='id_conf[$i]' value='{$lc_t_configuracion['id_conf']}' /></td>";
echo "<td>{$lc_t_configuracion['concepto']}</td>";
echo "<td><input type='text' size='40' name='valor[$i]'         value='{$lc_t_configuracion['valor']}' /></td>";
echo '</tr>';
++$i;
}
echo '<tr>';
echo "<td><input type='submit' value='submit' /></td>";
echo '</tr>';
echo "</form>";
echo '</table>';
?>

update.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Update Table</title>
</head>

<body>
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_admin = "localhost";
$database_admin = "xxx";
$username_admin = "xxx";
$password_admin = "xxx";
$admin = mysql_pconnect($hostname_admin, $username_admin, $password_admin) or trigger_error(mysql_error(),E_USER_ERROR); 

$size = count($_POST['valor']);

$i = 0;
while ($i < $size) {
$valor= $_POST['valor'][$i];
$id_conf = $_POST['id_conf'][$i];




$query = "UPDATE lc_t_configuracion  SET valor =  '$valor' WHERE id_conf =$id_conf LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
echo "$valor<br /><br /><em>Updated!</em><br /><br />";
++$i;
}
?>
</body>
</html>

请帮帮我

0 个答案:

没有答案