ok I am trying to make something really basic.... (php 4.3.9 mysql 4.0)
The admin panel consists of:
The view and add features work.
The edit feature refuses to do anything.
The delete feature only works as a link with a get method.
I want it to work as a post method with a submit button.
The other thing I cant figure out is why in the edit area, the second input box doesnt show all the data.
For example original data
<input type=text name=link value=Some Words>
in the Edit window it shows
<input type=text name=link value=Some>
I ran print_r($_POST) when submitting an edit and all the variables have the proper data in them, it just refuses to update the new data.
The admin panel consists of:
The view and add features work.
The edit feature refuses to do anything.
The delete feature only works as a link with a get method.
I want it to work as a post method with a submit button.
The other thing I cant figure out is why in the edit area, the second input box doesnt show all the data.
For example original data
<input type=text name=link value=Some Words>
in the Edit window it shows
<input type=text name=link value=Some>
I ran print_r($_POST) when submitting an edit and all the variables have the proper data in them, it just refuses to update the new data.
Code:
//top three links for viewing/adding/editing&deleting
<a href="links.php">View</a> <a href="links.php?action=add">Add</a> <a href="links.php?action=edit">Edit</a>
<br><br>
<?
mysql_connect("localhost", "root"); //connection works fine
mysql_select_db("database"); //db exists
$result = mysql_query("select * from table");
//edit data, data is pre-filled, or delete
if ($_GET['action'] == edit) {
$delete = $_POST['delete'];
//if ($_GET['action'] == del) { mysql_query("delete from table where id=".$id." limit 1"); }
if ($delete) { mysql_query("delete from table where id=".$id." limit 1");}
while ($row = mysql_fetch_assoc($result)) {
$id = $row[id];
echo"<form method=\"post\" action=\"links.php?action=edit\">
<input type=text value=$row[url] name=url>
<input type=text value=$row[website] name=website>
<input type=submit value=Edit name=modify>
<input type=submit value=Delete name=delete>
<input type=hidden value=$id name=id>
<a href=links.php?action=del&id=$id>Delete</a><br>
<textarea name=description rows=7 cols=40 style=\"margin:0;padding:0\">$row[description]</textarea></form>";
if ($_POST['modify']) mysql_query("update table set url='".$url."', set website='".$website."', set description='".$description."' where id = '".$id."' limit 1");
print_r($_POST); } //while
} //if bracket
?>