12-10-2009, 12:26 AM
i m new to php , i want to know how get data from multiple textboxes
can i name text boxes as like a arry, is it correct ,and how to display them
i return them like this echo $_POST[txtName[0]]
but it is not working , plz help me
this is the code
<html>
<head><title>Student Marks Calculator </title></head>
<body>
<form name ="My Data" method ="POST">
<table>
<tr>
<td>Name</td><td>Maths</td><td>Science</td><td>English</td>
</tr>
<tr
<td><input type="text" name=txtName[0]/></td>
<td><input type="text" name=txtMaths[0] /></td>
<td><input type="text" name=txtScience[0] /></td>
<td><input type="text" name=txtEnglish[0] /></td>
</tr>
<tr>
<td><input type="text" name=txtName[1]" /></td>
<td><input type="text" name=txtMaths[1]" /></td>
<td><input type="text" name=txtScience[1]" /></td>
<td><input type="text" name=txtEnglish[1]" /></td>
</tr>
<tr>
<td><input type="text" name=txtName[2] /></td>
<td><input type="text" name=txtMaths[2] /></td>
<td><input type="text" name=txtScience[2] /></td>
<td><input type="text" name=txtEnglish[2] /></td>
</tr>
<tr>
<td><input type="text" name=txtName[3] /></td>
<td><input type="text" name=txtMaths[3] /></td>
<td><input type="text" name=txtScience[3] /></td>
<td><input type="text" name=txtEnglish[3] /></td>
</tr>
<tr>
<td><input type="Submit" name="Report" value="Gen Report" /></td>
<td><input type="Submit" name="Reset" value="Reset" /></td>
</tr>
<?php
?>
</body>
</html>
can i name text boxes as like a arry, is it correct ,and how to display them
i return them like this echo $_POST[txtName[0]]
but it is not working , plz help me
this is the code
<html>
<head><title>Student Marks Calculator </title></head>
<body>
<form name ="My Data" method ="POST">
<table>
<tr>
<td>Name</td><td>Maths</td><td>Science</td><td>English</td>
</tr>
<tr
<td><input type="text" name=txtName[0]/></td>
<td><input type="text" name=txtMaths[0] /></td>
<td><input type="text" name=txtScience[0] /></td>
<td><input type="text" name=txtEnglish[0] /></td>
</tr>
<tr>
<td><input type="text" name=txtName[1]" /></td>
<td><input type="text" name=txtMaths[1]" /></td>
<td><input type="text" name=txtScience[1]" /></td>
<td><input type="text" name=txtEnglish[1]" /></td>
</tr>
<tr>
<td><input type="text" name=txtName[2] /></td>
<td><input type="text" name=txtMaths[2] /></td>
<td><input type="text" name=txtScience[2] /></td>
<td><input type="text" name=txtEnglish[2] /></td>
</tr>
<tr>
<td><input type="text" name=txtName[3] /></td>
<td><input type="text" name=txtMaths[3] /></td>
<td><input type="text" name=txtScience[3] /></td>
<td><input type="text" name=txtEnglish[3] /></td>
</tr>
<tr>
<td><input type="Submit" name="Report" value="Gen Report" /></td>
<td><input type="Submit" name="Reset" value="Reset" /></td>
</tr>
<?php
?>
</body>
</html>