473,499 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting multiple value from <input> to a table in PHP/MySQL

2 New Member
Hi to all Webmaster!
I have discover this problem when I inserted the scores of the students i a centain subject.

I am making a school project with regards to saving students' record.

first, I have to view all students under the certain subject and at the last field, I putted a form to put the scores of each student.

say '<input type=text name='score' size=10>' and number of '<input type=text>' is equal to the number of students.
I use the primary key of the students(IdNo) to be inserted at in the first field of the table(studScore).
this is the problem, i want to insert the score of each student from the '<input>' in the second field of the said table.
I am thinking that maybe it deals with array, but i really don't know how to formulate it.

The solution to this problem would be my key in finishing this project.

Anyone?

Thanks in advance.

God Speed!

heres my sample code:

////ADDING SCORE
$addscore=$_GET['score'];
if($addscore){
?>
<table border=1 bgcolor=#E7EBED width=829>
<form action='<? PHP_SELF; ?>' method=post>
<tr align=center>
<td colspan=8><font face="Tahoma" size="2" color=00000><b> Result/s</b></font> </td>
</tr>
<tr align=center>
<td colspan=8>&nbsp;</td>
</tr>
<?
}
$control=$_GET['subControl'];
$result = mysql_query( "SELECT students.IDNO,students.FIRSTNAME,students.LASTNAME ,students.MI,students.GENDER,students.COURSE,stude nts.YEAR FROM students,subjects,subjecttrans WHERE subjects.SUB_CONTROL=subjecttrans.SUBCONTROL AND subjecttrans.SUBCONTROL='$control' AND subjecttrans.IDNO=students.IDNO ORDER BY students.LASTNAME" ) or die ("SELECT Error: ".mysql_error());
$num_rows=mysql_num_rows($result);
//start if
if($num_rows > 0){
?>

<tr>
<th><font face="Tahoma" size="2" color=CC3300><b>Id No.</b></font> </th>
<th align=center><font face="Tahoma" size="2" color=CC3300>Students' Name</b></font> </th>
<th><font face="Tahoma" size="2" color=CC3300>Gender</b></font> </th>
<th><font face="Tahoma" size="2" color=CC3300>Course</b></font> </th>
<th><font face="Tahoma" size="2" color=CC3300>Year</b></font> </th>
<th><font face="Tahoma" size="2" color=CC3300>Add Score</b></font> </th>
</tr>
<tr align=center>
<td colspan=8>&nbsp;</td>
</tr>
<form action="<? PHP_SELF; ?>" method=post>

<? $i=0;
while ($i < $num_rows) {

?>
<tr height=15 class=off onmouseover="this.className='on'" onmouseout="this.className='off'">

<?

$id=mysql_result($result,$i,"IDNO");
$fn=mysql_result($result,$i,"FIRSTNAME");
$ln=mysql_result($result,$i,"LASTNAME");
$mi=mysql_result($result,$i,"MI");
$gen=mysql_result($result,$i,"GENDER");
$cors=mysql_result($result,$i,"COURSE");
$yer=mysql_result($result,$i,"YEAR");
?>
<td>&nbsp;<font face="Tahoma" size="2" color=666622><? echo $id; ?></font></td>
<td align=left>&nbsp;<font face="Tahoma" size="2" color=666622><? echo strtoupper($ln.","." ".$fn." ".$mi); ?> </font> </td>
<td>&nbsp;<font face="Tahoma" size="2" color=666622><? echo substr($gen,0,1); ?></font></td>
<td>&nbsp;<font face="Tahoma" size="2" color=666622><? echo strtoupper($cors); ?></font></td>
<td>&nbsp;<font face="Tahoma" size="2" color=666622><? echo strtoupper($yer); ?></font></td>
<-----this is the '<input>' i've tried to explain----->
<td>&nbsp;<font face="Tahoma" size="2" color=666622><input name="score" type="text"></td>


<?

$i++;


}

?>
</tr>
<tr height=20>
<td colspan=8 align=center>&nbsp;<font face="Tahoma" color=666666 size="2">****Nothing Follows****</font></td>

</tr>
<tr>
<td align=right>&nbsp;</td>
<td align=right>&nbsp;</td>
<td align=center><input size=40 type="submit" value="Save Checking" name="add" class="submit" /></td>
</tr>
</form>

</table>
Jan 31 '08 #1
1 2521
harshmaul
490 Recognized Expert Contributor
Hi,
Firstly next time you post please use code tag blocks it makes it easier for me to diagnose and help...

now possible solution,

If you want to assign the value of the score to a input text box you need to do something like this....

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $score = 10;
  3. //but instead of 10 you calculate the score
  4. ?>
  5. <input name="score" type="text" value="<?php echo $score ?>">
hope that helped
Jan 31 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2451
by: Don | last post by:
Using PHP, I'm creating an <input> tag. How do you delimit the text string for the value parm of an <input> tag, when the string contains the delimit char? Example: <input...value="This text...
3
2573
by: chirs | last post by:
Hi, I want to put a value in a cookie. The following code does not work. It does not store the box1.value in the cookie. How can I fix it? <input type="text" name="box1"...
5
13089
by: Jonathan Daggar | last post by:
Hello, I'm trying to put together a form with a very tight table formatting. However, every time I put an text-type input field in, the browser pads the area to the right of it with space. I've...
2
5943
by: not 2 swift | last post by:
I thought I would update an old page on which I had used a <INPUT TYPE=image ...> with a <BUTTON><IMG SRC=...></BUTTON> The problem is that <BUTTON> always provides a shadow/emboss effect. Can...
3
12172
by: iinet | last post by:
How can i set in my css a min width for input elements, but leave the max size dynamic? Ben
3
13125
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like...
2
5266
by: Mara Guida | last post by:
Hi, After I've populated a page with some <INPUT ...> elements I'd like to have access to whatever is written there. The best I've done (which does not work) is: ================ //...
2
3357
by: Richard Maher | last post by:
Hi, I'm trying to use the Visibility Style attribute for a Div to effectively PopUp a lightweight window with some additional context-sensitive information, when a user mouses over a given...
1
5484
by: test9991014 | last post by:
Hi folks, I've got something like this: <table> <tr> <td>1</td> <td align=center> <input type=text> </td>
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.