Jump to content

$_POST & Array ?? I think


simplyrichard

Recommended Posts

I'm having a litte trouble trying to think out the best process to collect a large number of items checkmarked. I will later have to insert a database row depending on each item selected here is an example of what I am trying to do.

 

List of open positions (Select all positions that you would like to apply for)

 

Office Manager

House Keeping

HR Administrator

Director of IT

 

Lets say the user selects three of the four above.

 

I call the $_POST['jobs_selected']; and now I have an array if I am not mistaken. How do I use the information within $_POST['jobs_selected']; I will need to insert each item selected into a different table. The user can select many jobs to apply to at once which could be different departments, I want to insert the application in each of the department's tables I have created. Therefore I need to know each job ID that the user selected. How would I do this?

 

Thanks for your help.

 

Richard  ;D

 

 

 

 

 

Link to comment
Share on other sites

after the setCookie command, the cookies are not available until the next page load....

 

that aside, i don't see the need for cookies here. once the info is submitted you want to store them in the tables right? do you have an INSERT commands written yet? how are the tables setup?

Link to comment
Share on other sites

I'm not ready to store them into a table. I want to store them until I need them. For me to use them I have to make sure an applicant has filled out an application and of course is logged in. I thought a cookie would work well because I have no information about the user until after they have registered or logged in.

Link to comment
Share on other sites


session_start();

foreach($_POST['jobs_selected'] as $job){

$_SESSION['jobs_selected'][] = $job;

}

 

if you wish to see how the info is stored

 


print_r($_SESSION['jobs_selected']);

 

I think that should work ok.

Link to comment
Share on other sites

Like this?

 

$_SESSION['jobs'] = $_POST['apply'];

foreach($_SESSION['jobs'] as $key => $value){
     // Do a db query
     // Do anything else you want
     // Each value now is referred to by using $job
     echo $key." ".$value'<br />';
}

 

yes, that should work, just make sure you do a session_start() at the beginning of the script. again, this assumes you don't want to use the data right away.

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.