How to Update Multiple Rows in one Click

Codes here !

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Mon Sep 17, 2012 2:26 am

How to Update Multiple Rows in one Click

Postby EngrChidi » Mon Sep 17, 2012 6:42 am

I am working on a Result processing application with this Table:
StudentName RegNo CourseCode Grade G.P
Bosco Lawal Ft/001 MTH 101
Caroline C. Ft/002 GS 201
Lawrence Leo Ft/003 Gs 201
Martins Lugard Ft/004 MTH 101
Jude James Ft/005 GS 201
Prisca Mandi Ft/006 PHY101
Ludacris John Ft/007 Gs 201

I wrote a select statement where courseCode = Gs 201
I created a FORM with a ‘SELECT’ and a ‘TEXT’ element for Grade and G.P respectively. I got the following output:
studentName RegNo Grade GP
Caroline C. Ft/002
Lawrence Leo Ft/003
Jude James Ft/005
Ludacris John Ft/007

This is the Code:
$cCode = $_POST["txtCcode"];

$query = "SELECT * FROM yr1cem1 where CourseCode= '$cCode' order by studentName";
$result = mysql_query($query)or die (mysql_error());

/* Display results in a table */
echo "<form name 'frm1' method = 'POST' action ='update.php'>
echo "<table border = '1' > ";
echo "<tr> <td> Name</td> <td> Reg Number</td> <td> Grade</td> <td> G.P</td> </tr> ";
while ($row = mysql_fetch_array($result))
echo "<tr > \n
<td> $studentName</td> \n
<td> <input type ='text' name='regi' id = 'regi' value = '$regNo'/> <td> \n
/*Create room for Upgrading of Students' G.P and Grades*/
<td> <input type ='text' name='txtGP' /> <td> \n
<td> <select name='sel'>
<option> Select</option>
<option value='A'> A</option>
<option value='B'> B</option>
<option value='C'> C</option>
<option value='D'> D</option>
<option value='E'> E</option>
<option value='F'> F</option>
</td> \n
</tr> \n";
echo "</table> \n";
echo "<input type ='submit' name ='btn' value ='Update /> ";
echo "</form> "


1. How can I Code the “Update.PHP” such that once the Students Grades and G.P are Entered by the Teacher, Clicking the Update Button will update all the Students at once.
2. Note: The Names Text Fields and Select Elements holding the G.P and Grades are not known;
3. Is there a better way to achieve this? From database design to the PHP codings?

Return to “mySQL & php coding”

Who is online

Users browsing this forum: Google [Bot] and 2 guests