954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

submit form with while loop

Hi all,
im sorry, im just a beginner, I had never come across to such circumstances.
Submit a form, with while loop, how am i going to retreive every single value submitted from the form?


<form name="pay" action="pay.php" method="post">

<?php
while ($row = mysqli_fetch_assoc($result)) {

echo '

<th width=70% colspan="3"> '.$row[project_name].'</th>
<tr>
<td class="alt" ><b>Contract Name</b></td>
<td class="alt"> '.$row[project_name].'</td>
</tr>
<tr>
<td class="alt" ><b> Pay</b></td>
<td class="alt">
<input type="text" name="base_pay" id="base_pay" size=10 value= "'.$row[base_pay].'">
</td>

</tr>
<tr>
<td class="alt" ><b>Bonus</b></td>
<td class="alt">
<input type="text" name="bonus" size=10 id="bonus" >
</td>
<td width=200 class="alt"></td>
</tr>
<tr>


';

}

?>
<tr><td class="alt" >
<input type="button" VALUE="Back" onClick="window.location.href='view_pay.php'"/>
<input type="submit" id="submit" value="Compute"/></td></tr>
</form>

can someone guide me,please. How to retreive all the value after submit
Thank you!

qwertpink
Newbie Poster
12 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

Use $_POST['fieldname'] to get the values submitted in the form (use for each field name and replace the word fieldname with your actual field names).

simplypixie
Posting Pro in Training
447 posts since Oct 2010
Reputation Points: 116
Solved Threads: 82
 

I solved it.
I cant use $_POST because there's while loop so there's multiple base pay and multiple bonus.
so my forms have to include

<td class="alt" ><b>Base Pay</b></td>
                                <td class="alt">
<input type="text" name="base_pay[]" id="base_pay" size=10  value= "'.$row[base_pay].'">
</td>


and at another page

$bonus = count($_POST['bonus']) ? $_POST['bonus'] : array();
$base_pay = count($_POST['base_pay']) ? $_POST['base_pay'] : array();
qwertpink
Newbie Poster
12 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: