Jump to content

how to post multiple inputs from mysql_fetch_array using a single submit button?


melbourne1815

Recommended Posts

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...

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.