I'm trying to create a Leaderboard site for a golf tournament, and the idea is for people to post ratings for each hole that will be added to the MySQL database, and then a separate score page will be displayed in the leaderboard. I am at the very beginning, but I am stuck in the fact that the user enters ratings.
My thinking is to store grades in a table with columns for the golfer, hole_num, and hole_score.
I am currently using this in my HTML to enter ratings.
<form action="insert.php" method="POST">
Golfer: <input type="text" name="golfer" />
<br>
Hole Number: <input type="number" name="hole_num" />
<br>
Hole Score: <input type="number" name="hole_score" />
<br>
<input type="Submit" value="Add"/></form>
insert.php:
<?php
include ('db_connect.php');
// Escape user inputs for security
$golfer = mysqli_real_escape_string($link, $_POST['golfer']);
$hole_num = mysqli_real_escape_string($link, $_POST['hole_num']);
$hole_score = mysqli_real_escape_string($link, $_POST['hole_score']);
// Attempt insert query execution
$sql = "INSERT INTO scores (golfer, hole_num, hole_score) VALUES('$golfer','$hole_num','$hole_score')";
mysqli_query($link, $sql);
// Close database connection
mysqli_close($link);
?>
, , "", "hole_num" "hole_score", . , 1 . , , , 18 , , , . , - , , db, golfer, hole_num hole_score. , . , , . , - .