- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经玩了好几个小时了,但没有效果,我一直在构建一个脚本,该脚本允许我通过在表格中编辑来编辑管理员中网页上的信息。我使用了一些教程等,但现在它只是不想更新数据库。
我有三个要素:
第一个:列表 - 工作正常
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("models/header.php");
// Connects to your Database
mysql_connect("localhost", "cl52-abcdef","abcdef") or die(mysql_error());
mysql_select_db("cl52-abcdef") or die(mysql_error());
$tbl_name="DealOne";
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from mysql </strong> </td>
</tr>
<tr>
<td align="center"><strong>Desc</strong></td>
<td align="center"><strong>Dest</strong></td>
<td align="center"><strong>RRP</strong></td>
<td align="center"><strong>Price Entry</strong></td>
<td align="center"><strong>Entries Avail</strong></td>
<td align="center"><strong>Update</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['holdesc1']; ?></td>
<td><? echo $rows['holdest1']; ?></td>
<td><? echo $rows['rrp1']; ?></td>
<td><? echo $rows['cpe1']; ?></td>
<td><? echo $rows['ea1']; ?></td>
<td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
?>
第二个:表单更新数据的地方
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("models/header.php");
// Connects to your Database
mysql_connect("localhost", "cl52-abcdef","abcdef") or die(mysql_error());
mysql_select_db("cl52-abcdef") or die(mysql_error());
$tbl_name="DealOne";
// get value of id that sent from address bar
$id=$_GET['id'];
// Retrieve data from database
$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<form name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td> </td>
<td colspan="3"><strong>Update data in mysql</strong> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"><strong>Desc</strong></td>
<td align="center"><strong>Dest</strong></td>
<td align="center"><strong>RRP</strong></td>
<td align="center"><strong>Price Entry</strong></td>
<td align="center"><strong>Entries Avail</strong></td>
</tr>
<tr>
<td> </td>
<td align="center"><input name="desc" type="text" id="holdesc1" value="<? echo $rows['holdesc1']; ?>" size="35">
</td>
<td align="center">
<input name="Destination" type="text" id="holdest1" value="<? echo $rows['holdest1']; ?>" size="35">
</td>
<td>
<input name="RRP" type="text" id="rrp1" value="<? echo $rows['rrp1']; ?>" size="8">
</td>
<td align="center">
<input name="Price per Entry" type="text" id="cpe1" value="<? echo $rows['cpe1']; ?>">
</td>
<td align="center">
<input name="Entries Available" type="text" id="ea1" value="<? echo $rows['ea1']; ?>" size="8">
</td>
</tr>
<tr>
<td> </td>
<td>
<input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>">
</td>
<td align="center">
<input type="submit" name="Submit" value="Submit">
</td>
<td> </td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?php
// close connection
mysql_close();
?>
最后是第三个,我相信它会更新数据库,但它没有:
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("models/header.php");
// Connects to your Database
mysql_connect("localhost", "cl52-abcdef","abcdef") or die(mysql_error());
mysql_select_db("cl52-abcdef") or die(mysql_error());
$tbl_name="DealOne";
// update data in mysql database
$sql="UPDATE $tbl_name SET holdesc1='$holdesc1', holdest1='$holdest1', rrp1='$rrp1', cpe1='$cpe1', ea1='$ea1' WHERE id='$id'";
$result=mysql_query($sql);
// if successfully updated.
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='view_posts.php'>View result</a>";
}
else {
echo "ERROR";
}
?>
关于如何让它发挥作用有什么想法或建议吗?提前致谢!!
最佳答案
您的 $tbl_name 未加引号。
你有
$sql="UPDATE $tbl_name SET holdesc1='$holdesc1', holdest1='$holdest1', rrp1='$rrp1', cpe1='$cpe1', ea1='$ea1' WHERE id='$id'";
我认为应该是:
$sql="UPDATE '$tbl_name' SET holdesc1='$holdesc1', holdest1='$holdest1', rrp1='$rrp1', cpe1='$cpe1', ea1='$ea1' WHERE id='$id'";
关于PHP SCRIPT - 执行时不更新数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21057373/
我知道 source 和 . 做同样的事情,如果标题中的其他命令对不一样,我会感到惊讶事情(因为我正在运行 bash 作为我的 shell,$SHELL [script] 和 bash [script
我在尝试启动第一个 super 账本网络时遇到此错误: $ ./byfn.sh -m up Starting with channel 'mychannel' and CLI timeout of '
哪个更好用或者更方便: ... 或 ... 最佳答案 你真的需要类型属性吗?如果您使用的是 HTML5,则不会。否则,是的。 HTML 4.01 和 XHTML 1.0 指定了 type属性是必需的,
哪个更好用或者更方便: ... 或 ... 最佳答案 你真的需要类型属性吗?如果您使用的是 HTML5,则不会。否则,是的。 HTML 4.01 和 XHTML 1.0 指定了 type属性是必需的,
使用此语法包含外部 javascript 文件的正确术语是什么: 是否包含script.js?执行了吗?是链接的吗?是叫吗?我刚刚运行了该文件吗? 最佳答案 我认为这里最常见的术语是加载外部 Jav
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: Why don't self-closing script tags work? 我刚刚发现 HTML 中的
没什么可说的了。我尝试寻找这意味着什么,但找不到。该脚本几个月来一直运行良好,并在 12 小时前停止,没有对其进行任何更改。手动运行显示此错误。 最佳答案 我遇到了同样的问题,我只需从脚本编辑器中单击
我是 Apps 脚本的新手,正在尝试了解使用另一个帐户在一个帐户中运行/触发脚本的基础知识。需要注意的是:我想在访问脚本的用户而不是拥有脚本的用户的情况下运行脚本——以便将运行时间分配给访问的用户。
我是 Apps 脚本的新手,正在尝试了解使用另一个帐户在一个帐户中运行/触发脚本的基础知识。需要注意的是:我想在访问脚本的用户而不是拥有脚本的用户的情况下运行脚本——以便将运行时间分配给访问的用户。
我最近遇到这个问题,我试图在我的 HTML 页面中导入多个 js 文件,如下 - 但我面临的问题是,它只加载第一个 js 文件,而其余的 js 文件没有加载。我还检查了浏览器中的网络部分,剩下的
Duplicate Why don’t self-closing script tags work? 我正在编写一个 ASP.net 页面,它在 JS 文件中有一些用于客户端身份验证的 Javascr
为什么以下行在许多浏览器(mozilla、IE)中不起作用? 为什么一定要这样设置? 最近我将我的项目从 XHTML 转换为 HTML5,我遇到了一些小但令人不安的不兼容性。 最佳答案 虽然脚本元
这个问题已经有答案了: Why don't self-closing script elements work? (12 个回答) 已关闭 7 年前。 经过两天的 Angular 与 Webpack
我在任何地方都找不到这个问题的答案;甚至在官方文档中也没有。我已经尝试自己编写代码,但它不起作用,所以它可能无法实现。 在下面的示例中,您可以使用条件颜色进行绘图: //STACKED EMAs
我正在通过串行端口使用 Tera Term 在板上进行一些测试。最近我发现我可以在 Tera Term 中编写一些脚本,所以我一直在做研究以帮助自动化并使测试更容易一些。 我知道 Tera Term
数组在 PineScript 中不可用。 有解决办法吗?有没有人开发过代码,作为数组使用? 我需要它做什么?我想计算每条趋势线或 S/R 水平的触及次数。 最佳答案 要实现计数器,您可以创建一个变量,
有没有办法创建一个指标来反射(reflect) Pine Script 中股票的当前价格?我需要这个指标,因为我需要在蜡烛关闭之前输入订单(当有特定的交叉时)并且回测数据是逐条提供的。我认为一个指标可
我的网站有一个脚本,如果从移动设备查看页面,格式和样式会发生变化。在网站的 2/3 页上,该脚本效果很好,正如我想要的那样。但是在最后一个上,用于更改格式和样式的脚本运行但未完全运行。我已经尝试从我的
我是否正确,市场上没有直接替代此流程: 在 chrome 插件商店中发布未列出 直接将链接分享给可以使用脚本的人 特别是,这些机制允许我使用我在所有 google dsoc 上编写的脚本。 随着转向市
我有一个简单的 Google Script 发布为具有匿名访问权限的网络应用程序。代码可用 here网络应用程序可用 here . code.gs function doGet() { retur
我是一名优秀的程序员,十分优秀!