I have the following form:
<form action="done.php" method="POST">
<!-- This hidden check box is used to check if submit is clicked.-->
<input type="hidden" name="check_submit" value="1" />
<!--All the applications are added to an array which we can then use in done.php-->
<applications><h2>Applications</h2><br><table border="0" cellspacing="10" cellpadding="10">
<tr>
<td><b>Application</b></td>
<td><b>UK</b></td>
<td><b>Spain</b></td>
<td><b>France</b></td>
<td><b>Benelux</b></td>
<td><b>Germany</b></td>
<td><b>Sweeden</b></td>
</tr>
<tr>
<td>hey</td>
<td><center><input type = "checkbox" name="hey[]" value ="heyuk"/></center></td>
<td><center><input type = "checkbox" name="hey[]" value ="heyspain"/></center></td>
<td><center><input type = "checkbox" name="hey[]" value ="heyfrance"/></center></td>
<td><center><input type = "checkbox" name="hey[]" value ="heybenelux"/></center></td>
<td><center><input type = "checkbox" name="hey[]" value ="heygermany"/></center></td>
<td><center><input type = "checkbox" name="hey[]" value ="heysweeden"/></center></td>
</tr>
<input type="submit" value="Update">
</submitb>
</form>
Then my done.php receives the data when it is posted.
<?php
// First we execute our common code to connection to the database and start the session
require("common.php");
//Check whether the form has been submitted
if (array_key_exists('check_submit', $_POST)) {
//Converts the new line characters (\n) in the text area into HTML line breaks (the <br /> tag)
if ( isset($_POST['hey']) ) {
$print = implode(', ', $_POST['hey']); //Converts an array into a single string
echo $print;
echo('<br>');
}
So this all works perfectly up to now. However, I have a database called hey which looks as follows:
What I want to happen next is that if a country is selected for that application, it adds a 1 to the database in the relevant field.
I am unsure how to proceed with this as I can't guarantee currently what position in the array each element is in. Please could you advise me on this? Thank you.