I want it to show the newest post first then second and so on, how do i manage such thing? and it doesnt show the email address for some reason... :( and last but not least: how do i add like timestamp like yyyy/mm/ddd hh:mm ?
<form method="post" onsubmit="#" action="gpost.php">
<fieldset>
Namn:<br><input name="gnamn" id="gnamn" type="text" size="20">
<br>E-post:<br><input name="gemail" id="gemail" type="text" size="20">
<br>Meddelande:<br>
<textarea name="gmeddelande" id="gmeddelande" cols="20" rows="10">
</textarea>
<br><br>
<input name="submit" type="submit" value="Sänd">
</fieldset>
</form>
<?php
$host="localhost";
$user="my user";
$pass="mypasswor :D";
$dbname="pelle";
$con=mysqli_connect($host,$user,$pass,$dbname);
if (mysqli_connect_errno($con))
{
echo "Misslyckades att ansluta till mysql: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT name,message FROM guestbook");
while($row = mysqli_fetch_array($result))
{ ?>
<div id="post">
<header><h3><?php echo $row['name']; ?></h3></header>
<p><?php echo $row['email']; ?></p>
<p><?php echo $row['message']; ?></p>
</div>
<?php }
mysqli_close($con);
?>
and heres my gpost.php
<?php
$host="localhost";
$user="my usernamen";
$pass="my password";
dbname="pelle";
$con=mysqli_connect($host,$user,$pass,$dbname);
if (mysqli_connect_errno($con))
{
echo "<h1>Failed to connect to MySQL: " . mysqli_connect_error() ."</h1>";
}
$name=$_POST['gnamn'];
$email=$_POST['gemail'];
$message=$_POST['gmeddelande'];
$sql="INSERT INTO guestbook(name,email,message) VALUES('$name','$email','$message')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
else
echo "Values Stored in our Database!";
mysqli_close($con);
?>