Page 1 of 1

Question from a new guy.

Posted: Fri Aug 15, 2008 4:20 am
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!

Re: Question from a new guy.

Posted: Fri Aug 15, 2008 11:33 am
by Christopher
Sorry, what is the question?

Re: Question from a new guy.

Posted: Fri Aug 15, 2008 6:23 pm
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:

Re: Question from a new guy.

Posted: Fri Aug 15, 2008 8:24 pm
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