melbourne1815 Posted February 3, 2012 Share Posted February 3, 2012 hi i need help on posting multiple inputs in a single button...while using mysql_fetch_array here is my codes: <? $re6 = mysql_query('select username from users where course = "BSIT" and yearlevel = "FOURTH"'); ?> <br /> <h1>Post Grade</h1> <h1>IT, Fourth Year</h1> <br />Please fill the following form to send The Grade<br /> <? $n = 0; while($row = mysql_fetch_row($re6)) { echo'<form action="grade_post.php" method="post">'; echo'Recipient<span class="small">(Username)</span><input type="text" value="'.$row['username'].'" readonly="readonly" id="recip" name="recip[' . $n . ']" />'; echo'Subject<input type="text" value="'.htmlentities($otitle, ENT_QUOTES, 'UTF-8').'" id="title" name="title[' . $n . ']" />'; echo'<input type="hidden" value="FOURTH" id="year" name="year[' . $n . ']" />'; echo'<input type="hidden" value="FIRST" id="sem" name="sem[' . $n . ']" />'; echo'Grade<input type="text" id="message" name="message[' . $n . ']" ><br />'; ++$n; } ?> i get all my recipients in every input type, but when i tried to post it in my database not all of them are posted rather only one of them are posted in my database ...what i want to happen is that all of my recipients in every input type will be posted in my database with different ids'...help pls... Quote Link to comment https://forums.phpfreaks.com/topic/256292-how-to-post-multiple-inputs-from-mysql_fetch_array-using-a-single-submit-button/ Share on other sites More sharing options...
MadTechie Posted February 3, 2012 Share Posted February 3, 2012 Move the echo'<form action="grade_post.php" method="post">'; out of the loop and also close the form echo'<form action="grade_post.php" method="post">'; while($row = mysql_fetch_row($re6)){ echo'Recipient<span class="small">(Username)</span><input type="text" value="'.$row['username'].'" readonly="readonly" id="recip" name="recip[' . $n . ']" />'; echo'Subject<input type="text" value="'.htmlentities($otitle, ENT_QUOTES, 'UTF-8').'" id="title" name="title[' . $n . ']" />'; echo'<input type="hidden" value="FOURTH" id="year" name="year[' . $n . ']" />'; echo'<input type="hidden" value="FIRST" id="sem" name="sem[' . $n . ']" />'; echo'Grade<input type="text" id="message" name="message[' . $n . ']" ><br />'; ++$n; } echo'</form>'; Oh and i haven't but you should also apply the array to the ID's as well as the name ie echo'Grade<input type="text" id="message[' . $n . ']" name="message[' . $n . ']" ><br />'; once thats done your get an array So this to echo the message foreach($_POST['message'] as $msg){ echo "$msg<br />\n"; } I'm off night all! Quote Link to comment https://forums.phpfreaks.com/topic/256292-how-to-post-multiple-inputs-from-mysql_fetch_array-using-a-single-submit-button/#findComment-1313884 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.