I have a database in MYSQL and it contains 2 tables:
Table: political_party
+----------+--------------------+-------+
| party_id | party_abbreviation | party |
+----------+--------------------+-------+
Table: polling_party_result
+----+------+-----------------+
| id | p_id | number_of_votes |
+----+------+-----------------+
I am writing a PHP program that outputs a form, which UPDATES the political_party_result table WHERE the id runs from 1 to X.. The problem I'm facing is that on the form, the id relates to the party_abbreviation column in the above political_party table.
That is 1(in the political_party_result table) should bring out AP(from the political_party table)
2 = ADC
3 = PDP
etc..
Here is my HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML INEC</title>
</head>
<body>
<form action="inechp.php" method="post" name="form1">
ID: <input name="id" type="text" /> <br /> <br />
Polling Unit: <input name="pid" type="text" /> <br /> <br />
Number of Votes: <input name="votes" type="text" /> <br /> <br />
<input type="submit" /> <br />
</form>
<form action="inechp.php" method="post" name="form2">
Polling Unit: <input name="unit" type="text" /> <br />
Number of Votes: <input name="nov" type="text" /> <br />
<input type="submit" />
</form>
</body>
</html>
Here is my PHP code:
<?php
$con = mysqli_connect("localhost", "root", "", "inec_results");
mysqli_query($con, "UPDATE inec_results.polling_party_result SET p_id ='$_POST[pid]' , number_of_votes = '$_POST[votes]' WHERE id = '$_POST[id]'");
?>
Forgive me if my explanations weren't satisfactory as I'm bit new to PHP.