Skip to content

Instantly share code, notes, and snippets.

@AndreasJacobsen
Created March 13, 2015 19:09
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 AndreasJacobsen/c7fb29a883e78cb82e5d to your computer and use it in GitHub Desktop.
Save AndreasJacobsen/c7fb29a883e78cb82e5d to your computer and use it in GitHub Desktop.
<?php
if(isset($_POST["next"])) {
$db = mysqli_connect("localhost", "root", "", "VM");
if (!$db) {
die("Feil i knytning til databasen!");
} else {
echo "knyttet til databse! <br>";
}
$fornavn = $_POST["firstname"];
$etternavn = $_POST["surname"];
$nasjonalitet = $_POST["nationality"];
$droppliste = $_POST["droppliste"];
$sql = "INSERT INTO competitor(name,surname,nationality,excersize)";
$sql .= "VALUES ('$fornavn','$etternavn','$nasjonalitet','$droppliste')";
$resultat = mysqli_query($db, $sql);
}
$sql = "SELECT * FROM competitor";
$resultat = mysqli_query($db,$sql);
if(!$resultat)
{
echo "FEIL!";
}
echo '<table>';
while ($rad=mysqli_fetch_array($resultat,MYSQLI_ASSOC)) {
echo '<tr>';
echo '<td>'.$rad["name"].'</td>';
echo '<td>'.$rad["surname"].'</td>';
echo '<td>'.$rad["nationality"].'</td>';
echo '<td>'.$rad["excersize"].'</td>';
echo '</tr>';
}
echo '<table>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment