Jump to content

I think in need loops


chrispos

Recommended Posts

Hi All,

 

and thanks for your help on my last problem now solved.

 

What i am doing is building a job site and it needs info put in from job seekers regarding their qualifications. Some will have 2 some may have 10 and so on. I need to set up a system that I can put say 10 text boxes in a form that can then go in a MySQL. I only want the filled out boxes to go into the database and not the ones left blank. I have no idea as to where to start with but I think I need to loop through until it comes to the last filled out box but not enter the blank text boxes. i have no idea where to start on this one so if any one has thoughts on this it would be great.

 

Thank you all for your help in the past.

Link to comment
Share on other sites

Thank you its the loop I am after. The box link was great but it is getting the number of boxes then loop through then the insert and that is the bit I have no idea with. I hope that makes sense. I normally use

$something = $_POST['something']

 

But in this case I would not know how many boxes and what they were called.

 

Link to comment
Share on other sites

here's something to get you started.

<form method="post" action="some_page.php">
<input name="qualification[]" type="text" /><br />
<input name="qualification[]" type="text" /><br />
<input name="qualification[]" type="text" />
<input type="submit" value="submit" id="submit" name="submit" />
</form>

 

if (isset($_POST['submit'])) {
  for ($i=0; $i<count($_POST['qualification']); $i++) {
    if ($_POST['qualification']) {
      // insert into database
    }
  }
}

 

that's just a quick code off the top of my head. there may be syntax errors but i hope you get the idea. there are other ways but this is the "quick and dirty" way.

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.