Hi ... maybe for many of you this is a simple issue, but not for me ...
I need to know how to update records using a web form (not using phpmyadmin or some kind of editor ). my database is created with mysql and i would like to use php ..
The user must look for a field defined and then if the user decide to change / update that record i must to show all the related information and then insert the new fields ...
thanks in advance for any help !
greetings ..
update database information
Moderator: General Moderators
Here's a helpful, and very visual tutorial:
http://www.spoono.com/php/tutorials/tutorial.php?id=23 -- There way is designed to all go on one page.
The main idea - to actually update the article:
$sql = "UPDATE whatever SET title='$title',content='$content',edit_date='NOW()' WHERE id=$edit_id";
Another way to grab the id:
This will make it so if http://www.website.com/page.php?id=1 is visited, $edit_id will equal 1. then in the database connect just do "SELECT*, FROM whatever WHERE id='$edit_id'" Then if you make a form field value=$title it will display $title from row 1.
http://www.spoono.com/php/tutorials/tutorial.php?id=23 -- There way is designed to all go on one page.
The main idea - to actually update the article:
$sql = "UPDATE whatever SET title='$title',content='$content',edit_date='NOW()' WHERE id=$edit_id";
Another way to grab the id:
Code: Select all
function get_id(){
$pattern = "/.*\/\w+.php.id.()/i";
$replacement = "\${1}";
$edit_id = preg_replace($pattern, $replacement, $_SERVER['REQUEST_URI']);
return $edit_id;
};
$edit_id = get_id();re: update record information ..
Thanks for the tips .. but the address http://www.spoono.com/php/tutorials/tutorial.php?id=23 is not working
Would you please letme know if is really correct the web site that you suggest ? ..
thanks again .. !
Would you please letme know if is really correct the web site that you suggest ? ..
thanks again .. !
hmm... very strange. It works for me in both of the posts. Try going to the link below and then click on Edit Row in Mysql in the right hand column. If that doesn't work then go to spoono.com > Programming > PHP > Tutorials (view all) > and then Edit row in mysql.
http://www.spoono.com/php/tutorials/
http://www.spoono.com/php/tutorials/
http://www.spoono.com/php/tutorials/
http://www.spoono.com/php/tutorials/