Skip to content

Instantly share code, notes, and snippets.

@AndreasJacobsen
Created March 13, 2015 16:00
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/0c4949cd22348204702b to your computer and use it in GitHub Desktop.
Save AndreasJacobsen/0c4949cd22348204702b to your computer and use it in GitHub Desktop.
<?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