Forum Moderators: coopster
There are a couple of options using the GET method. Typically we see ...
while (getting data from the database) {
print '<td>' . $row['username'] . '</td>' .
'<td><a href="edit_user.php?id=' . $row['id'] . '>Edit</a></td>' .
'<td><a href="delete_user.php?id=' . $row['id'] . '>Delete</a></td>';
}
// which will give us something along the lines of ...
+------+------+--------+
¦ User ¦ Edit ¦ Delete ¦
+------+------+--------+
¦ John ¦ Edit ¦ Delete ¦
¦ Suzy ¦ Edit ¦ Delete ¦
¦ Bill ¦ Edit ¦ Delete ¦
¦ Joan ¦ Edit ¦ Delete ¦
¦ Eddy ¦ Edit ¦ Delete ¦
+------+------+--------+ It works and it works just fine. Another option of course would be to drop in a URL without the query string and employ something like Apache's mod_rewrite engine to parse the static url and invoke our PHP script ...
while (getting data from the database) {
print '<td>' . $row['username'] . '</td>' .
'<td><a href="edit_user/' . $row['id'] . '>Edit</a></td>' .
'<td><a href="delete_user/' . $row['id'] . '>Delete</a></td>';
} The POST method is pretty self explanatory -- a form and submit buttons. I find myself trying to find new ways around the obviously simple routes every once in awhile and thought I'd ask others what they use, and why.
Anybody care to discuss?
I'm not a big fan of the query string on the GET method but in some cases it works just fine.
I try to keep them out of public areas, but I think anyone who wears the title "admin" should be able to handle seeing a query string in a url. Since these areas are usually password protected, it also removes worries related to SEO.
As for the rest, I definitely know what you mean. If you remember way back, I was for a while enamored with the idea of displaying first as formatted text and then having it turn into an editable textarea upon clicking (there's a good example on the quirksmode.org site). That way you could have it both ways - nice looking for reading, but still editable if necessary.
The problem is that the data on the site I was thinking of doing it for was not formatted really, so there was no particular advantage to doing it in the long run. I still like the idea, but I've only done it fooling around on my experiments.
I usually try to do a table with checkboxes if possible, so the admin doesn't have to submit a form for each and every change. In your GET example, the admin would have to click on a link, wait for the page to reload, click on a link, wait for the page. I find that trying, so I like to give them a form that's more like
+------+-------------+-----------+
¦ User ¦ User Level ¦ Delete ¦
+------+--------_----+-----------+
¦ John ¦[select box] ¦[check box]¦
¦ Suzy ¦[select box] ¦[check box]¦
¦ Bill ¦[select box] ¦[check box]¦
¦ Joan ¦[select box] ¦[check box]¦
¦ Eddy ¦[select box] ¦[check box]¦
+------+-------------+-----------+
¦ [submit button ¦
---------------------------------+
I would much rather batch process if possible.