Skip to content

Instantly share code, notes, and snippets.

@AndreasJacobsen
Created March 13, 2015 15:57
Embed
What would you like to do?
<?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