|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
i'm just a new learner of PHP... so i would like to know a bit about udating data..
let's say if have already have a form to submit the data.. which contains the "insert" syntax, then i would like to know where to put the "UPDATE your_table SET your_field='$variable' WHERE id_field='$id'"? should i use the same form or i should create another form with the same interface or any other way to put it?.. tq.. |
|
#2
|
|||
|
|||
|
What I do for some news systems I make for my sites is I have a file like listnews.php which grabs everything from the DB and lists all the news like it would on the main news page, however this page is password protected so only admins can access it. Under each news item I put 2 links, Edit & Delete. the link for edit would be like
PHP Code:
editnews.php would then show a form and query the db extracting data from the table WHERE id = $id and prefill the form fields. After that when I edit & click submit the query would then run the update query. I'm not so good at explaining but just seeing if I could help ![]()
__________________
![]() ![]() "Only Linux users see the end of crashes." - Pl4t0 |
|
#3
|
|||
|
|||
|
its probally best to have two forms, one for insert and one for update, when you update the file, once you click submit, you place the update query one the page after the submit button
|
|
#4
|
|||
|
|||
|
tq wAr-AnGeL and Ben for u'r concern..
Ben, it seems must have a file name for example : update.php3 which contains : <?php . . . UPDATE tbl_jual SET lokasi='$lokasi' WHERE item_no='$item_no'; $result = mysql_db_query($dbname, $query) or die(mysql_error()); if ($result) @header("Location:isijual.php"); ?> is that correct? |
|
#5
|
|||
|
|||
|
yeah something like that should do it
|
|
#6
|
|||
|
|||
|
Linda,
Don't forget to store your UPDATE query in a variable... If you just type it out like "UPDATE tbl_jual SET lokasi='$lokasi' WHERE item_no='$item_no';" you'll get an error. Make sure to do it like this: $query = UPDATE tbl_jual SET lokasi='$lokasi' WHERE item_no='$item_no';
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#7
|
|||
|
|||
|
tq for remind me :-)
|
|
#8
|
|||
|
|||
|
dear cute linda,
definetly, you should have another form or script to update the entry. well, you can also have a script which uses swtich statement to display the forms and scripts as well. and dont lupa to check your entry, i.e. empty ones , or invalid entries. and as Frankie said, you should have a variable contains your query. good luck Aku Hanya InSan Kerdil
__________________
Rathaur ====================== Knowledge is Power |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > updating data.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|