Jump to content

semi-advanced PHP form techniques, deep need for guidance (imgs/code included)


Lyricsride

Recommended Posts

Hey everyone, i'm trying to create a form which allows a user to state which projects he is workin on in an association, and what his position is in the selected project. Then i want his selections to be recorded into MySQL for later retrieval.

Here is my form CURRENTLY

[url=http://codes.concordia.ca/codes/assets/img/temp/problem/1.png]http://codes.concordia.ca/codes/assets/img/temp/problem/1.png[/url]
I have the first page working, no problems.

[url=http://codes.concordia.ca/codes/assets/img/temp/problem/2.png]
http://codes.concordia.ca/codes/assets/img/temp/problem/2.png[/url]
Second page as you can see has recorded the first page data fine.

[url=http://codes.concordia.ca/codes/assets/img/temp/problem/3.png]http://codes.concordia.ca/codes/assets/img/temp/problem/3.png[/url]
Just an example of the user selecting multiple projects. I have no experience with javascript so do not know how to control it well. My duplicated project fields spawn below the submit button no matter what i do. they are currently spawned by by pressing the text "add extra project"

[url=http://codes.concordia.ca/codes/assets/img/temp/problem/4.png]http://codes.concordia.ca/codes/assets/img/temp/problem/4.png[/url]
As we move on to the third page i've tried to put the project/position selection into arrays. i failed. they do not print out and i am quite stumped as to how to work it. I am only a beginner and complicated form-related arrays that must be put into MySQL still cause me difficulty.

[url=http://codes.concordia.ca/codes/assets/img/temp/problem/5.png]http://codes.concordia.ca/codes/assets/img/temp/problem/5.png[/url]
The fourth page works fine, expcet for the second page data, again

All of this takes place on one single page. Here is the code, i know it's a bit much so i will answer questions as best i can.

The code was too much for this forum to upload so i've put it here [url=http://codes.concordia.ca/codes/assets/img/temp/problem/6.png]http://codes.concordia.ca/codes/assets/img/temp/problem/6.png[/url] instead.

Thank you all for your help, i know that somehow i must use PHP arrays, and javascript, but i just can't seem to crack this. And i've found NO tutorials or issues exact enough to solve my problem.

Thank you!
Link to comment
Share on other sites

aight, well...
if your sure your getting data, if your not use this: print_r($en_id) and then for the other one as well, if you are sure... try using the implode command, example: $en_id = implode(",", $_POST['enterprises'])

try it.. c if it works... cuz i have a feeling about the javascript...
Link to comment
Share on other sites

thank you very much for your reply. I have some screenshots of your test:

The selection >> http://codes.concordia.ca/codes/assets/img/temp/problem/7.png

The result >> http://codes.concordia.ca/codes/assets/img/temp/problem/8.png

As you can see, the array SEEMS to be building correctly. Now, what do i do with it?! I need to take that data, and stick it into a database. The solution is some sort of loop that inserts each record?

Thanks

PS: also, how in gods name do i get those additional selections when they spawn to do so not at the bottom of the forum below even the submit button?!
Link to comment
Share on other sites

well if you want it to output numbers then use the for function. or watever. simply go like this:
[code=php:0]
$en_id = explode(",", $_POST['enterprises']); //split the array
$mepos_id = explode(",", $_POST['me_positions']);

for($i = 0; $i < count($en_id); $i++){
//you could add in the number translations etc here.
if($i != count($en_id)-1){ $output_en .= $en_id[$i].", "; }else{ $output_en .= $en_id[$i]; }
if($i != count($mepos_id)-1){ $output_mepos .= $mepos_id[$i].", "; }else{ $output_mepos .= $mepos_id[$i]; }
}

echo $output_en." / ".$output_mepos;
[/code]

there probably is easier ways. and i didnt check to see if that works. but give it a burl. you can play with it a bit...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.