PHP-DB - How to Update Multiple Rows in one Click (General)

by micheal.burns1, Saturday, September 22, 2012, 07:03 (1883 days ago)

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

&lt /body &gt
&lt /html &gt
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?

Outsourcing Services | Outsourcing Companies | Hire PHP Programmer

Complete thread:

 RSS Feed of thread

powered by my little forum