Jump to content


Photo

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


  • Please log in to reply
6 replies to this topic

#1 Lyricsride

Lyricsride
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationQuebec

Posted 22 October 2006 - 04:01 AM

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

http://codes.concord...p/problem/1.png
I have the first page working, no problems.


http://codes.concordia.ca/codes/assets/img/temp/problem/2.png

Second page as you can see has recorded the first page data fine.

http://codes.concord...p/problem/3.png
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"

http://codes.concord...p/problem/4.png
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.

http://codes.concord...p/problem/5.png
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 http://codes.concord...p/problem/6.png 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!
Lyricsride

#2 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 22 October 2006 - 06:54 AM

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...
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#3 Lyricsride

Lyricsride
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationQuebec

Posted 22 October 2006 - 04:53 PM

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

The selection >> http://codes.concord...p/problem/7.png

The result >> http://codes.concord...p/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?!
Lyricsride

#4 Lyricsride

Lyricsride
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationQuebec

Posted 22 October 2006 - 07:50 PM

^bump  :-\
Lyricsride

#5 Lyricsride

Lyricsride
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationQuebec

Posted 23 October 2006 - 01:46 AM

bump :-[
Lyricsride

#6 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 23 October 2006 - 09:13 AM

well if you want it to output numbers then use the for function. or watever. simply go like this:
$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;

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...
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#7 Lyricsride

Lyricsride
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts
  • LocationQuebec

Posted 23 October 2006 - 02:27 PM

thanks a lot for your reply, i'll see about this ;)
Lyricsride




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users