Created
March 13, 2015 15:57
-
-
Save AndreasJacobsen/c78327d2d5ab9c24ac2e 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 | |
$db = new mysqli(); | |
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); | |
$res = $db->query($sql); | |
if (!$res) { | |
echo "Feil i registrering ikke null"; | |
} elseif (mysqli_affected_rows($db) == 0) { | |
echo "Feil i registreringen"; | |
} | |
} | |
$sql = "SELECT * FROM competitor"; | |
$resultat = mysqli_query($db,$sql); | |
if(!$resultat) | |
{ | |
echo "FEIL!"; | |
} | |
while ($rad=mysqli_fetch_array($resultat,MYSQLI_ASSOC)) { | |
?> | |
<table> | |
<td><?php echo $rad["name"];?></td> | |
<td><?php echo $rad["surname"];?></td> | |
<td><?php echo $rad["nationality"];?></td> | |
<td><?php echo $rad["excersize"];?></td> | |
</table> | |
<? | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment