PHP Form and Database Help Please

Please support our PHP advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Thread Solved

Join Date: Apr 2007
Posts: 26
Reputation: mattyb15 is an unknown quantity at this point 
Solved Threads: 0
mattyb15 mattyb15 is offline Offline
Light Poster

PHP Form and Database Help Please

 
0
  #1
Sep 16th, 2008
Okay. I'm a php newbie.

I have a form where the user enters their name.

I then on the next form I want it to access the database and add 1 to the row named 'number' that matches the persons name that they previously entered. If the name does not exist, I want it to create new data for that person.

Any help would be much appreciated.
If I helped +rep please,
Thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: PHP Form and Database Help Please

 
0
  #2
Sep 16th, 2008
wat u need code or suggestion?
Help as an alias

I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: PHP Form and Database Help Please

 
0
  #3
Sep 16th, 2008
if u need suggestion....

first u check weather the data is present or not.
if not then insert a new row.
Help as an alias

I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 26
Reputation: mattyb15 is an unknown quantity at this point 
Solved Threads: 0
mattyb15 mattyb15 is offline Offline
Light Poster

Re: PHP Form and Database Help Please

 
0
  #4
Sep 16th, 2008
The code would be great. I'm new to PHP and don't really know how to use it properly yet.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: PHP Form and Database Help Please

 
0
  #5
Sep 16th, 2008
  1. $result=mysql_query('select * from user where table='.$user_id.'');
  2. if(mysql_num_rows($result) == 0){
  3. $insert_user= 'insert into user set id='.$user_id.'';
  4. mysql_query($insert_user) || die(mysql_error());
  5. }


modify as ur enties
Help as an alias

I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 213
Reputation: nikesh.yadav is an unknown quantity at this point 
Solved Threads: 17
nikesh.yadav's Avatar
nikesh.yadav nikesh.yadav is offline Offline
Posting Whiz in Training

Re: PHP Form and Database Help Please

 
0
  #6
Sep 16th, 2008
sorry forgot last enrty

  1.  
  2.  
  3. $result=mysql_query('select * from tablename where id='.$user_id.'');
  4. if(mysql_num_rows($result) == 0){
  5. $insert_user= 'insert into tablename set id='.$user_id.'';
  6. mysql_query($insert_user) || die(mysql_error());
  7. }



modify as ur enties
Help as an alias

I think programming is great................
Tour Travel weblink by me and about Tour ,
Go To My Home Page and I m in Webdevelopment.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 26
Reputation: mattyb15 is an unknown quantity at this point 
Solved Threads: 0
mattyb15 mattyb15 is offline Offline
Light Poster

Re: PHP Form and Database Help Please

 
0
  #7
Sep 16th, 2008
Sorry, but how would I go about adding one to that persons 'number' row?
If I helped +rep please,
Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: PHP Form and Database Help Please

 
0
  #8
Sep 16th, 2008
i think you are not complete with your posts.....

Please provide your thread clearly...
Last edited by Shanti Chepuru; Sep 16th, 2008 at 7:30 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 26
Reputation: mattyb15 is an unknown quantity at this point 
Solved Threads: 0
mattyb15 mattyb15 is offline Offline
Light Poster

Re: PHP Form and Database Help Please

 
0
  #9
Sep 16th, 2008
This is my code so far.

  1. $name = $_REQUEST['name'];
  2. $set = $_REQUEST['set'];
  3. $email = $_REQUEST['email'];
  4.  
  5. $con = mysql_connect("XXXXXXXXXXXXXX","XXXXXXX","XXXXX");
  6. if (!$con)
  7. {
  8. die('Could not connect: ' . mysql_error());
  9. }
  10.  
  11. mysql_select_db("a6114672_dope", $con);
  12.  
  13. $result=mysql_query('select * from turf_table where id='.$name.'');
  14. if(mysql_num_rows($result) == 0){
  15. $insert_user= 'insert into turf_table set id='.$name.'';
  16. mysql_query($insert_user) || die(mysql_error());
  17. }
  18.  
  19. mysql_close($con);
If I helped +rep please,
Thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 26
Reputation: mattyb15 is an unknown quantity at this point 
Solved Threads: 0
mattyb15 mattyb15 is offline Offline
Light Poster

Re: PHP Form and Database Help Please

 
0
  #10
Sep 16th, 2008
For example, my data table is:

Name: Number:
Matthew 20


And I want to add 1 to the number in the number column.
If I helped +rep please,
Thanks
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 3055 | Replies: 31
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC