Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PHP Form Submits But Only Updates Last Row. I am trying to update multiple data in the performance table but only the last row is

PHP Form Submits But Only Updates Last Row.

I am trying to update multiple data in the performance table but only the last row is being updated. In the performance table there is a composite key: Player Id and Practice number. Each player can have multiple practice numbers. I am trying to update the practice performance data of each player but for some reason only the last practice data is being updated. Performance table is shown below.

image text in transcribed

This is the code which is not working and is only updating the last practice data for each player Id:

image text in transcribed

This is the code for update.php:

include("connection.php");

$query = "update performance set practise_no='$_POST[practise_no]',time='$_POST[time]',points='$_POST[points]' where id = '$_POST[id]' AND practise_no ='$_POST[practise_no]'";

$query_run = mysqli_query($link,$query);

?>

In the where clause, both id and practise number is given so that we can identify the unique row in the performance table (Such as, for which id and for which practise number the data should be updated).

Please tell me what have I done wrong. On the internet, I have seen people facing similar problem are using arrays to solve this issue. Please can you show me how its done or by using any other method.

score id practise_no laptime 1 1 02:01:19.000000 98 1 2 02:02:14.000000 23 13 02:01:14.000000 74 2 1 02:01:14.000000 34 TH
10 11 12 13 14 15 16 17 on

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions