Jump to content

Recommended Posts

I'm creating a system to calculate the marks of a students examination.

 

db1

The students is asked to select the correct answer out of 3 given answers (A, B or C). All those answers will be stored in a MYSQL db (below is the db design example). 

 

                  |  Question 1  |  Question 2  |  Question 3  |  Question 4  |  Question 5  |  Your Marks  | 

Mickey        |          A        |          C        |          C        |          A        |          B        |          0        |

Nathan      |          C        |          B        |          C        |          B        |          A        |          0        |

Jeff            |          A        |          C        |          C        |          A        |          B        |          0        |

 

db2

The correct answers will be stored in a separate db.  The correct answers will be updated after the exam is over. (below is the db design example).

                |  Question 1  |  Question 2  |  Question 3  |  Question 4  |  Question 5  | 

Section A  |          A        |          C        |          C        |          A        |          B          |

Section B  |          C        |          B        |          C        |          B        |          A          |

Section C  |          A        |          C        |          C        |          A        |          B          |

 

Now here come my question.... How do I automatically update the Your Marks column when I post the correct answers to db2.

 

Basically I need a way to match db2 results against db1 for each row and update Your Marks with the COUNT of the matching answers for each student.

 

Example: Here's how db1 should be when the answers are updated in db2.

                  |  Question 1  |  Question 2  |  Question 3  |  Question 4  |  Question 5  |  Your Marks  | 

Mickey        |          A        |          C        |          C        |          A        |          B        |        5        |

Nathan      |          C        |          B        |          C        |          B        |          B        |          4        |

Jeff            |          B        |          B        |          B        |          B        |          B        |          1        |

 

Hope my question is clear. I really appreciate your help. Thank you!

Link to comment
https://forums.phpfreaks.com/topic/220556-automatically-update-marks/
Share on other sites

oops!  the db2 design is like this ( the db with the correct answers)... sorry!

             

|  Question 1  |  Question 2  |  Question 3  |  Question 4  |  Question 5  | 

Section A  |          A        |          C        |          C        |          A        |          B          |

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.