Created
March 13, 2015 19:09
-
-
Save AndreasJacobsen/c7fb29a883e78cb82e5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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