PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 2nd, 2000, 06:11 PM
netman816 netman816 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 8 netman816 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey everyone,

I was hoping someone could help me. This is what I want to do:

I want to make it so that when someone enters text into a form, the text is entered into a mysql database. However, the way I want it to work is, when the person enters text into that field at a later date, it updates it instead of adding another row in the db.

Can someone please tell me the easiest way to do this? Thanks.

Sorry about the bad wording.

Reply With Quote
  #2  
Old June 2nd, 2000, 08:44 PM
Dr_E_lectric Dr_E_lectric is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 36 Dr_E_lectric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
<form method="post" action=" <?php echo $PHP_SELF ?>">
<br>
Your text<br>
<input type="Text" name="your var" size="30">
Enter your ID<br>
<input type="Text" name="id" size="30"> </form>

<?php
$hostname = "localhost";
$username = "your username";
$password = "your password";
$dbName = "your database";
$userstable = "your table";

if ($submit) {
MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database");

@mysql_select_db("$dbName") or die("Unable to select database");
$result = mysql_query ("SELECT * FROM $userstable WHERE id = '$id'");

$query = "REPLACE INTO $userstable SET your table colum name = '$your var'";
$result = MYSQL_QUERY($query);
}

?>

Put this in your html this will work to update an exsisting record you will have to adapt this to your needs. I hope this helps you


------------------
good luck Dr.E.L.

[This message has been edited by Dr_E_lectric (edited June 02, 2000).]

[This message has been edited by Dr_E_lectric (edited June 02, 2000).]

Reply With Quote
  #3  
Old June 5th, 2000, 04:23 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned (not really)
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 1999
Location: Brussels, Belgium
Posts: 14,628 Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)Sepodati User rank is General 51st Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 6 Days 2 h 39 m 6 sec
Reputation Power: 4375
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
I don't see the reason for that first mysql_db_query statement with the SELECT.

Instead of REPLACE, you can also use UPDATE:

mysql_db_query("UPDATE $table SET text='$input_text' WHERE id='$id'");

---John Holmes
---www.SepodatiCreations.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Updating a mysql row's contents, not adding a new row

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap