Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 3rd, 2009, 1:15 PM   #1
ronny22
Newbie
 
Join Date: Sep 2008
Posts: 23
Rep Power: 0 ronny22 is on a distinguished road
how do you make a add, edit and delete forms

hi everyone

please is the anyone who can show me how to make a add, edit and a delete forms

my database is called gamelist
on my database i have products table
which has
id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`body` text NOT NULL,
`price` decimal(8,0) NOT NULL,
`image` varchar(50) NOT NULL,
`stock` int(11) NOT NULL,
PRIMARY KEY (`id`)

what i wished to do is be able to
add to this table
edit to this table
and also be able to delete form this table
but by forms

so if i had form that allows me to input in to table it be great
i have an idea how the add can be made but no idea how
i can make an edit form
because for the edit form i would like to see the title the body (which is a description of the item on my website) the price the image and the stock

so then i can edit and update it

and i have no idea how i can make an delete
i mean i have some kind of idea where i can show all product titles on screen and have a delete button next to it so i can delete it

IF the is someone who can show me how to make this please help
ronny22 is offline   Reply With Quote
Old Sep 4th, 2009, 12:59 AM   #2
ZER01NE1NE
Kyle Edwards
 
ZER01NE1NE's Avatar
 
Join Date: Sep 2009
Location: Albany, NY
Posts: 11
Rep Power: 0 ZER01NE1NE is on a distinguished road
Send a message via AIM to ZER01NE1NE
Re: how do you make a add, edit and delete forms

Well, for the edit form, you should insert PHP code into the form that retrieves the information from the database. For example:

php Syntax (Toggle Plain Text)
  1. <?php
  2. $result = mysql_query("SELECT `title` FROM `products` WHERE `id` = $id;"); // replace $id with the ID variable
  3. $row = mysql_fetch_assoc($result);
  4. $title = $row['title'];
  5. echo "<input type='text' name='title' value='$title' />\n";
  6. ?>

etc.

To delete an entry, try this:

php Syntax (Toggle Plain Text)
  1. <?php
  2. mysql_query("DELETE FROM `products` WHERE `id` = $id;"); // replace $id with the ID variable
  3. ?>
__________________
"In order to create an apple pie from scratch, you must first create the entire universe." - Carl Sagan

Last edited by ZER01NE1NE; Sep 4th, 2009 at 1:10 AM.
ZER01NE1NE is offline   Reply With Quote
Old Sep 4th, 2009, 4:29 AM   #3
CoderGuru
Professional Programmer
 
Join Date: Jan 2009
Location: Dallas, Texas, USA
Posts: 328
Rep Power: 9 CoderGuru is on a distinguished road
Re: how do you make a add, edit and delete forms

Suggestion: always do the following to stop SQL injections since your PHP might not be setup to automatically add slashes to requests

'where id="' . mysql_escape_string($_GET['id']) .'"'
'
CoderGuru is offline   Reply With Quote
Old Sep 4th, 2009, 12:31 PM   #4
ZER01NE1NE
Kyle Edwards
 
ZER01NE1NE's Avatar
 
Join Date: Sep 2009
Location: Albany, NY
Posts: 11
Rep Power: 0 ZER01NE1NE is on a distinguished road
Send a message via AIM to ZER01NE1NE
Re: how do you make a add, edit and delete forms

Quote:
Originally Posted by CoderGuru View Post
Suggestion: always do the following to stop SQL injections since your PHP might not be setup to automatically add slashes to requests

'where id="' . mysql_escape_string($_GET['id']) .'"'
'
Thanks lol I keep forgetting to do that.
__________________
"In order to create an apple pie from scratch, you must first create the entire universe." - Carl Sagan
ZER01NE1NE is offline   Reply With Quote
Old Sep 4th, 2009, 12:32 PM   #5
ronny22
Newbie
 
Join Date: Sep 2008
Posts: 23
Rep Power: 0 ronny22 is on a distinguished road
Re: how do you make a add, edit and delete forms

hi guys thanks for the reply
but is the anything u guys know that i could use that would have forms

you know soo you can type it in the form then submit
ronny22 is offline   Reply With Quote
Old Sep 4th, 2009, 3:56 PM   #6
ZER01NE1NE
Kyle Edwards
 
ZER01NE1NE's Avatar
 
Join Date: Sep 2009
Location: Albany, NY
Posts: 11
Rep Power: 0 ZER01NE1NE is on a distinguished road
Send a message via AIM to ZER01NE1NE
Re: how do you make a add, edit and delete forms

Here's some sample HTML code for a form, but you'd have to program your PHP code around this:

html Syntax (Toggle Plain Text)
  1. <form action="submit.php" method="POST">
  2. <p>
  3. Title:
  4. <input type="text" name="title" />
  5. </p>
  6. <p>
  7. Body:
  8. <textarea name="body"></textarea>
  9. </p>
  10. <p>
  11. Price:
  12. <input type="text" name="price" maxlength="8" />
  13. </p>
  14. <p>
  15. Image:
  16. <!-- Is `image` a file upload? -->
  17. <input type="file" name="image" />
  18. </p>
  19. <p>
  20. Stock:
  21. <input type="text" name="stock" maxlength="11" />
  22. </p>
  23. <p>
  24. <!-- Change "new" to "edit" to edit items. You'll need to modify your PHP script accordingly. -->
  25. <input type="hidden" name="action" value="new" />
  26. <input type="submit" value="Go!" />
  27. </p>
  28. </form>
__________________
"In order to create an apple pie from scratch, you must first create the entire universe." - Carl Sagan
ZER01NE1NE is offline   Reply With Quote
Old Sep 4th, 2009, 7:38 PM   #7
ronny22
Newbie
 
Join Date: Sep 2008
Posts: 23
Rep Power: 0 ronny22 is on a distinguished road
Re: how do you make a add, edit and delete forms

thank you

so how do i connect this with php
ronny22 is offline   Reply With Quote
Old Sep 4th, 2009, 10:29 PM   #8
CoderGuru
Professional Programmer
 
Join Date: Jan 2009
Location: Dallas, Texas, USA
Posts: 328
Rep Power: 9 CoderGuru is on a distinguished road
Re: how do you make a add, edit and delete forms

Ronny, in a non negative way it appears you want everything done for you, automatically, so thankfully their is a better solution that PHP for you. You might want to check out visual web developer and move from PHP to ASP.net. It does 90% of the work for you such as generate your forms via drag and drop. http://www.microsoft.com/express/vwd/default.aspx

Also if this is a route you choose, which I truly suggest if it's possible, then heres TONS of free videos on learning it and how to use it: http://www.asp.net/learn/
CoderGuru is offline   Reply With Quote
Old Sep 4th, 2009, 10:30 PM   #9
CoderGuru
Professional Programmer
 
Join Date: Jan 2009
Location: Dallas, Texas, USA
Posts: 328
Rep Power: 9 CoderGuru is on a distinguished road
Re: how do you make a add, edit and delete forms

Quote:
Originally Posted by ZER01NE1NE View Post
Thanks lol I keep forgetting to do that.
NP =]. But yeh lol, it can be a very costly mistake ;/
CoderGuru is offline   Reply With Quote
Old Sep 4th, 2009, 11:05 PM   #10
ronny22
Newbie
 
Join Date: Sep 2008
Posts: 23
Rep Power: 0 ronny22 is on a distinguished road
Re: how do you make a add, edit and delete forms

Quote:
Originally Posted by CoderGuru View Post
Ronny, in a non negative way it appears you want everything done for you, automatically, so thankfully their is a better solution that PHP for you. You might want to check out visual web developer and move from PHP to ASP.net. It does 90% of the work for you such as generate your forms via drag and drop. http://www.microsoft.com/express/vwd/default.aspx

Also if this is a route you choose, which I truly suggest if it's possible, then heres TONS of free videos on learning it and how to use it: http://www.asp.net/learn/
thanks for the consideration
i will try and have ago first on the php as everyone has replyed to this thread with helping advise including yourself which i say thanks for

ill have ago and hopefully someone will check if its right and guide as you all are right now
ronny22 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make posts editable. Rashakil Community Announcements and Feedback 25 Apr 12th, 2009 11:25 PM
Creating an Edit Table AFProgMan ASP.NET 0 Oct 24th, 2008 2:21 PM
Cannot delete posts? titaniumdecoy Community Announcements and Feedback 13 Oct 31st, 2007 4:45 PM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 10:04 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC