Jump to content
Killersites Forums

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


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 post
Share on other sites
  • 3 weeks later...
  • 4 weeks later...

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

 

 

What does your grade_post.php file look like??

 

What does your database structure look like?

 

 

i'm not sure if this helps but you can try doing something like here:

 

<?php 

//first build the query....
$re6 = mysql_query('select username from users where course = "BSIT" and yearlevel = "FOURTH"') or die(mysql_error());

//lets create the html form tag outside of our loop.
?>
<form action="grade_post.php" method="post">
<?php

while($row = mysql_fetch_array($re6, MYSQL_ASSOC))
{
	//this is where our loop begins....	
	//we only want to loop our input fields with the different usernames as values inside them.
?>
	<input type="text" name="recip[]" value="<?php echo $row['username']; ?>"><br>
<?php
}

?>
<input type="submit" value="Submit Form!">
</form> 

<?php 
//the code above should output all your users in a seperate input. (i'm not sure why you would need this done but if that's what you want, then this is how you would do it.)


//if you explain a bit more in detail on what you are looking to do then maybe i can help you solve this problem.
?>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...