I am writing a sort of custom Administrative UI.
I have implemented the php code that inserts and reads records from the DB table.
The records are visualized in a table in the UI in the below pattern:
test title
Added: 2011-12-29 17:34:35
test2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test title
Added: 2011-12-29 17:34:35 tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test title2 Added: 2011-12-29 17:34:35 test22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have the following structure for my database table:
TABLE news ( guid , lang , title , content , date, PRIMARY KEY (guid, lang) )
guid is generated with php com_create_guid () function.
How can I implement buttons Edit and Delete beside each item?
Thanks a lot!
<form action="action.php" method="POST"> <input type="hidden" name="record_id" value="12"> <input type="submit" value="Edit" name="doedit"> <input type="submit" value="Delete" name="dodelete"> </form>
In action.php:
if (isset($_POST['doedit'])){do smth.}
if (isset($_POST['dodelete'])){do smth.}
you can make links instead giving each different url containing action and record id as GET parameters.
Suppose you have a file action.php. For record number 12 the "edit" link will go to "action.php?do=edit&record=12", the "delete" link will go to "action.php?do=delete&record=12".
In action.php:
$do=$_GET['do']; //you should add some validation of $_GET
$rec=$_GET['record']; if ($do=='edit'){do smth.} if ($do=='delete'){do smth.}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.