Created
March 13, 2015 16:00
-
-
Save AndreasJacobsen/0c4949cd22348204702b 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)) { | |
?> | |
<?php | |
echo $rad["name"]; | |
echo '<table>'; | |
echo '<td>'.$rad["name"]; | |
echo '<td>'.$rad["surname"]; | |
echo '<td>'.$rad["nationality"]; | |
echo '<td>'.$rad["excersize"]; | |
} | |
/* | |
<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