删除按钮每个表行 [英] Delete button for each table row
问题描述
我设法成功地读取和我有以下code数据库显示数据:
http://pastebin.com/rjZfBWZX
我也产生了对表:)点击删除按钮调用obrisi.php这是应该删除该行,但我搞砸了事情的每一行删除按钮:S这里的obrisi.php code:
I manage to succesfully read and display data from my database with the following code: http://pastebin.com/rjZfBWZX I also generate a delete button for each row of the table :) Clicking the delete button calls "obrisi.php" which is supposed to delete that row but I messed something up :S Here's obrisi.php code:
我得到一个解析错误:语法错误,意想不到的发件人(T_STRING)表示:S
I'm getting a Parse error: syntax error, unexpected 'FROM' (T_STRING) :S
推荐答案
让我们尝试和_GET,而不是_POST做到这一点。
Let's try and do it with _GET instead of _POST.
在你的主code,你需要换线39(输入):
In your main code you need to change line 39 (the input) from:
echo "<td>" . " <input type='submit' id= '$id' . ' value='Delete' >" . "</td>";
到
echo "<td><a href='obrisi.php?id=$id'>Delete</a></td>";
在您obrisi.php变线3(ID设置):
In your obrisi.php change line 3 (the id setup) from:
$id = $_POST['id'];
到
$id = $_GET['id'];
最后作为一个很好的补充,由PHP标签结束前添加以下行的obrisi.php文件的末尾重定向回主画面。
And finally as a nice addition, redirect back to the main page by adding the following line at the end of the obrisi.php file before the closing of the php tag.
header('location:index.php');
凡的index.php你主页的名称。
Where index.php the name of the main page you have.
这篇关于删除按钮每个表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!