Skip to content

Instantly share code, notes, and snippets.

@Domin8-IPTV
Created September 29, 2020 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Domin8-IPTV/4e0f2b5c19badfc2dfdb9e2cecd9e6eb to your computer and use it in GitHub Desktop.
Save Domin8-IPTV/4e0f2b5c19badfc2dfdb9e2cecd9e6eb to your computer and use it in GitHub Desktop.
insert weekly score
<?php
// MADE BY M4UNDY
// ENTER SHOOTERS WEEKLY SCORES INTO MYSQL DATABASE
$shooter = mysqli_real_escape_string($link, $_POST['shooter']);
$values = [];
foreach ($_POST['week_score'] as $key => $score) {
$score = trim(mysqli_real_escape_string($link, $score));
if (!empty($score)) {
$values[] = "('$shooter','$key','$score')";
}
}
if (!empty($values)) {
$values = implode (' , ', $values);
$sql = "INSERT INTO scores (shooter, week_num, week_score) VALUES $values";
mysqli_query($link, $sql);
}
mysqli_close($link);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment