Created
March 13, 2015 10:17
-
-
Save AndreasJacobsen/f90ca132e42cdf4fbea1 to your computer and use it in GitHub Desktop.
side2
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"]; | |
echo $fornavn . "<br>"; | |
echo $etternavn . "<br>"; | |
echo $nasjonalitet . "<br>"; | |
echo $droppliste . "<br>"; | |
$sql = 'INSERT INTO competitor ("name,surname,nationality,excersize")'; | |
$sql .="Values ('$fornavn','$etternavn','$nasjonalitet','$droppliste'"; | |
$resultat = mysqli_query($db,$sql); | |
if(!$resultat) { | |
echo "Feil i registrering"; | |
} | |
elseif (mysqli_affected_rows($db)==0) { | |
echo "Feil i registreringen"; | |
} | |
} | |
?> | |
<h2>Her er dataen fra databasen</h2> | |
<table> | |
<tr> | |
<th>Fornavn</th><th>Etternavn</th><th>Adresse</th> | |
<th>Nationality</th><th>droppliste</th> | |
</tr> | |
<?php | |
$sql = "SELECT * FROM competitor"; | |
$resultat = mysqli_query($db,$sql); | |
if (!$resultat) | |
{ | |
echo "Feil med lesing fra databasen!!"; | |
} | |
while ($rad=mysqli_fetch_array($resultat,MYSQL_ASSOC)){ | |
?> | |
<tr> | |
<td<?php echo $rad["name"]?>></td> | |
<td><?php echo $rad["surname"]?></td> | |
<td><?php echo $rad["nationality"]?></td> | |
<td><?php echo $rad["excersize"]?></td> | |
<td></td> | |
<td></td> | |
<tr> | |
<?php | |
} | |
mysqli_close($db); | |
?> | |
</tr> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment