Question from a new guy.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CodeNoob
Forum Newbie
Posts: 2
Joined: Fri Aug 15, 2008 3:52 am

Question from a new guy.

Post by CodeNoob »

Hey all
I'm quite new to the whole PHP scripting, so please don't assume i know stuff :)

Basic info:

Database name: parcvx
Database tables:
"parcv1table"
columns: id | servername | selectproject | typeserver | cabinet | aantalru | publicpoort | privatepoort | notes | ipnummer
(id = auto incr.)

and

"parcv2table"
columns: id | opleverid | checklist | value
(id = auto incr.)

--------------------------------------------------------------------------------------
The files i'm working with:

Here are the 3 files i created:

Code: Select all

 
http://www.uploading.com/files/ZFNRQZIS/index.html.html
http://www.uploading.com/files/R9RGACUB ... n.php.html
http://www.uploading.com/files/JCYOVU6B ... n.php.html
 
Index.html = the form that has to be filled in and send to "verwerken.php"
verwerken.php = Checking if the form has been filled in properly + inserting info into database
uitvoeren.php = printing the choices made in the form.

----------------------------------------------------------------

Here is where i get stuck:

Problem #1:
the column "opleverid" (within table "parcv2table") has to contain the "id" from the entry that has been made and inserted into the database that session. So someone fills in the form, mysql creates an "id" automaticly, that id has to be inserted/copied to the column "opleverid"

Problem #2:
the column "value" (within table "parcv2table") has to contain a simple "Y" or "N" depending on what has been selected within the "radiobutton-area" on the form.

Problem #3:
the column "checklist" (within table "parcv2table") has to contain the text for the proper value.
I.E:
someone selected "Yes" for "bsmtp", so it should be insterted into the database like:

Code: Select all

 
| id   | opleverid | checklist   | value |
|  30 | 5            | bsmtp  |      | Y         |
 
---------------------------------------------------------------

This is where my knowledge stops, I hope i didn't scare you guys off with this long Openings post.

Thanks in advance for the help that i might get.

Salut!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Question from a new guy.

Post by Christopher »

Sorry, what is the question?
(#10850)
CodeNoob
Forum Newbie
Posts: 2
Joined: Fri Aug 15, 2008 3:52 am

Re: Question from a new guy.

Post by CodeNoob »

Sorry, i assumed the question was clear.

Well, the question is: "How do i solve Problem # 1,2 and 3"
Please keep in mind you're posting to a noob who has to lookup mysql command to navigate to the columns :oops:
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Question from a new guy.

Post by Jade »

Problem 1: mysql has a function called mysql_insert_id(); it returns the ID of the row that was just inserted. So you could store that result into the session, however it needs to be called directly after the insert is made.

Problem 2: you'll need to use an if-statement. When a radio button is selected the value for the selected button is returned. If the button doesn't have a value then the obvious thing is to insert a N into the field. If the button has a value then you'd insert a Y.

Problem 3: for the checklist you'll need to do a loop from the $_POST variable. Only things that have been selected from checkboxes will be returned to the $_POST values. That way you can loop through all the $_POST values for the checkboxes and insert a row for each one into the table.

I would suggest taking some php and html tutorials. A lot of the questions you're asking are more "form" related then anything else. :D
Post Reply