General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 19th, 2002, 11:50 PM
lindacomel lindacomel is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 lindacomel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question updating data..

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..

Reply With Quote
  #2  
Old August 20th, 2002, 12:15 AM
wAr-AnGeL wAr-AnGeL is offline
Forum Security
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Behind You
Posts: 479 wAr-AnGeL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 50 sec
Reputation Power: 7
Send a message via ICQ to wAr-AnGeL Send a message via AIM to wAr-AnGeL
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:
<a href="editnews.php?id=<?php echo("$rows[id]"); ?>">Edit</a

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

Reply With Quote
  #3  
Old August 20th, 2002, 12:55 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #4  
Old August 20th, 2002, 04:22 AM
lindacomel lindacomel is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 lindacomel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question updating data..

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?

Reply With Quote
  #5  
Old August 20th, 2002, 05:09 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
yeah something like that should do it

Reply With Quote
  #6  
Old August 20th, 2002, 08:57 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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

Reply With Quote
  #7  
Old August 20th, 2002, 09:40 AM
lindacomel lindacomel is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 lindacomel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile thanks

tq for remind me :-)

Reply With Quote
  #8  
Old August 20th, 2002, 12:04 PM
rathaur rathaur is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Malaysia
Posts: 82 rathaur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 57 sec
Reputation Power: 7
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > updating data..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT