shihabudheen Posted March 7, 2011 Share Posted March 7, 2011 i want insert data from text box in html form.there are many text boxes gave name using 2 loops..plz tell how can insert data to table?plz reply [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/229861-inserting-data-to-table-in-my-sql/ Share on other sites More sharing options...
flolam Posted March 7, 2011 Share Posted March 7, 2011 you should name your input boxes like this: Quote <table> <tr> <td><input type="text" name="t[1][1]" /></td> <td><input type="text" name="t[1][2]" /></td> <td><input type="text" name="t[1][3]" /></td> </tr> <tr> <td><input type="text" name="t[2][1]" /></td> <td><input type="text" name="t[2][2]" /></td> <td><input type="text" name="t[2][3]" /></td> </tr> </table> and your $_POST["t"] will be a multidimensional array (use print_r($_POST["t"]) to see what it looks like) which you can iterate over and use to insert into the db Quote Link to comment https://forums.phpfreaks.com/topic/229861-inserting-data-to-table-in-my-sql/#findComment-1183930 Share on other sites More sharing options...
shihabudheen Posted March 7, 2011 Author Share Posted March 7, 2011 tx for reply..i want to create more than hundread textbox,so that giving name directly is to difficult.plz tell how can i create and give name to textbox using for loop.. <?php echo "<table border=0>"; for ($j = 1; $j <= 40; $j++) { echo "<tr>"; for ($i = 1; $i <= 7; $i++) { echo "<td>"; echo "<input type=text name=t.[$j].[$i] >";//here getting mistakes :( echo"</td>"; } echo "</tr>"; } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/229861-inserting-data-to-table-in-my-sql/#findComment-1183947 Share on other sites More sharing options...
flolam Posted March 7, 2011 Share Posted March 7, 2011 you are not using quotes around your html attribute values and the dots don't belong there echo "<input type='text' name='t[$j][$i]' />"; Quote Link to comment https://forums.phpfreaks.com/topic/229861-inserting-data-to-table-in-my-sql/#findComment-1183951 Share on other sites More sharing options...
shihabudheen Posted March 7, 2011 Author Share Posted March 7, 2011 thanks for reply..plz tell how can i post the value from t[1][2 ]?$a = $_POST["t".$j.$i];?? Quote Link to comment https://forums.phpfreaks.com/topic/229861-inserting-data-to-table-in-my-sql/#findComment-1184129 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.