Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ID对编辑按钮代码无效_Php - Fatal编程技术网

Php ID对编辑按钮代码无效

Php ID对编辑按钮代码无效,php,Php,我有一个代码,显示存储在数据库中的数据。我想制作一个编辑按钮或链接,允许我编辑数据。我有一个表,它以列和行的形式显示数据 我的编辑代码片段 我犯了错误!345当我点击我的编辑按钮时,我知道它正在查询数据库,但我不知道为什么它告诉我我的ID有错误 根据要求,以下是显示编辑链接的“我的表格代码”的外观: $result=$conn->query$sql; 如果$result&&$result->num_rows>0{ //每行的输出数据 回显数据库中当前的内容? 图表 日期 回溯 开始摇摆交易 结

我有一个代码,显示存储在数据库中的数据。我想制作一个编辑按钮或链接,允许我编辑数据。我有一个表,它以列和行的形式显示数据

我的编辑代码片段

我犯了错误!345当我点击我的编辑按钮时,我知道它正在查询数据库,但我不知道为什么它告诉我我的ID有错误

根据要求,以下是显示编辑链接的“我的表格代码”的外观:

$result=$conn->query$sql; 如果$result&&$result->num_rows>0{ //每行的输出数据 回显数据库中当前的内容? 图表 日期 回溯 开始摇摆交易 结束摇摆交易 公牛旗 熊旗 均线交叉 交易工具 ; 而$row=mysqli\u fetch\u array$result{ 回响 echo.$row[图表日期];echo; echo.$row[图表回溯]; echo.$row[图表\u开始\u摆动\u交易]; echo.$row[图表\u结束\u摆动\u交易]; echo.$row[图表和标志]; echo.$row[图表标志]; echo.$row[图表\u ema\u交叉]; echo.$row[图表交易工具]; } 回响 }否则{ 回声0结果;
}这是PHP而不是javascript/jQuery,除此之外,我无法确定您发布的代码的错误,因为您有太多的右大括号}请执行以下操作:echo SELECT*FROM charts,其中newId=$newId;然后手动复制并粘贴回显的内容到数据库服务器中,以查看返回的内容。我得到:1054-where子句中的未知列“$newId”,但脚本正在尝试获取更新数据的ID。我发布了一半的代码,显示正在获取和显示的更新数据,因此我如何修改代码以使其生效工作?你能把全部代码都贴出来吗?你说的是一个编辑链接,它没有显示在你的问题中
// once saved, redirect back to the view page
 header("Location: insertchart.php"); 
 }
 }
 else
 {
 // if the 'id' isn't valid, display an error
 echo 'Error!123';
 }
 }
 else
 // if the form hasn't been submitted, get the data from the db and display the form
 {

 // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
 if (isset($_GET['newId']) && is_numeric($_GET['newId']) && $_GET['newId'] > 0)
 {
 // query db
 $newId = $_GET['newId'];
 $result = mysql_query("SELECT * FROM charts WHERE newId=$newId")
 or die(mysql_error()); 
 $row = mysql_fetch_array($result);

 // check that the 'id' matches up with a row in the databse
 if($row)
 {

 // get data from db
 $charts_date = $row['charts_date'];
 $charts_retrace = $row['charts_retrace'];
$charts_start_of_swing_trade = $row['charts_start_of_swing_trade'];
$charts_end_of_swing_trade = $row['charts_end_of_swing_trade'];
$charts_bullflag = $row['charts_bullflag'];
$charts_bearflag = $row['charts_bearflag'];
$charts_ema_crossover = $row['charts_ema_crossover'];
$charts_trading_instrument = $row['charts_trading_instrument'];

 // show form
 renderForm($newId, $charts_date, $charts_retrace, $charts_start_of_swing_trade, $charts_end_of_swing_trade, $charts_bullflag, $charts_bearflag, $charts_ema_crossover, $charts_trading_instrument, '');
 }
 else
 // if no match, display result
 {
 echo "No results!";
 }
 }
 else
 // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
 {
 echo 'Error!345';
 }
 }
?>