I have a basic form with just 1 text area and a submit button. Once submitted, it sends the name entered into a MySQL table.
The table structure is; ID , name , score,
The ID is AI. The name is user input and the score has a default of 0.
Then, I have an output page, which is where I need the help. On the output page, I have made my connection checked my connection caught my ASSOC's array and dropped it into a little HTML table to keep it organised, and I have added a checkbox to the end of each row.
Now, what I'm trying to do is: when any of the checkboxes are checked, I need a query to run to add 1 to the current value of score in the record.
Here is my code so far and YES it is very basic so far and it does work. I know I have to add some security to it and a lot of formatting but those can happen once I get the project working....
Here is my code:
<html>
<head>
<title> DaTaBaSe CoNeCtIoN TeStInG PaGe </title>
</head>
<body bgcolor="000000">
<font color="FF0000">
<?php
include ('conection.php');
//define $result as $con and run the query $sql
$result = $conn->query($sql);
//if number of rows in the table is higher 0 draw the table
if ($result->num_rows > 0) {
echo
"<table border= 5 bordercolor= #0000FF><tr><th><font color=#FF0000>ID</th><th><font color=#FF0000>Name</th></tr>";
//output the data
while($row = $result ->fetch_assoc()) {
//add the results to populate the table
echo "<tr><td><font color= #FF0000>".$row [id]."</td><td><font color= #FF0000>".$row["name"]."</td><td><font color= #FF0000>".$row["score"]."</td><td><input type= checkbox name=win>".$row["win"]."</td></tr>";
}
echo "</table>";
} else {
echo "0 results found";
}
$conn->close();
?>
</font>
</body>
</html>