Skriv en hilsen til oss da vel!
if ($notall == 1) { ?>Vennligst fyll ut alle feltene
} ?>//////////////////////////////// // This is where we connect to the database for reading. //////////////////////////////// mysql_pconnect("mysql.stud.ntnu.no","torivaha_kull23","einstein") or die("Unable to connect to SQL server"); mysql_select_db("torivaha_kull23") or die("Unable to select database"); //////////////////////////////// // This is where we count the number of entries. //////////////////////////////// $query = "SELECT COUNT(*) FROM guests"; $numguests = mysql_query($query) or die("Select Failed!"); $numguest = mysql_fetch_array($numguests); ?>
echo $numguest[0]; ?> personer har lagt inn en hilsen.
//////////////////////////////// // This is where we decide to get all the entries or just the last 20. // This variable is set by just adding a '?complete=1' after the URL. //////////////////////////////// if ($complete == 1) { $query = "SELECT * FROM guests ORDER BY guest_time DESC"; } else { $query = "SELECT * FROM guests ORDER BY guest_time DESC LIMIT 20"; } $guests = mysql_query($query) or die("Select Failed!"); ?> //////////////////////////////// // This will loop as long as there are records waiting to be processed. // Notice the plain HTML inside the while loop structure. PHP is flexable // enough to allow you to break into and out of the "code" at any point. //////////////////////////////// while ($guest = mysql_fetch_array($guests)) { ?>Navn: echo $guest['guest_name']; ?> | Epost: echo $guest['guest_email']; ?> | //////////////////////////////// // The database has a timestamp record type that we can use to show the // date the guestbook was filled out. //////////////////////////////// $datefromdb = $guest['guest_time']; $year = substr($datefromdb,0,4); $mon = substr($datefromdb,4,2); $day = substr($datefromdb,6,2); $hour = substr($datefromdb,8,2); $min = substr($datefromdb,10,2); $sec = substr($datefromdb,12,2); $orgdate = date("l F dS, Y h:i A",mktime($hour,$min,$sec,$mon,$day,$year)); ?> Dato: echo $orgdate; ?> |
echo $guest['guest_message']; ?> |
} ?>