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
https://forums.phpfreaks.com/topic/228014-i-think-in-need-loops/
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.

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.