Har lavet en simpel tagwall. Håber du kan bruge det..
tagwall.php:
<?
session_start();
$hostname = "";
$username = "";
$password = "";
$database = "";
$conn = mysql_connect("$hostname","$username","$password");
mysql_select_db("$database");
if($_GET['delete'] == "all") {
$delete = ("TRUNCATE TABLE tagwall");
$delete_query = mysql_query($delete) or die (mysql_error());
echo "Alle besked er blevet slettet!
<meta http-equiv='refresh' content='1.5;url=tagwall.php'>";
} elseif($_GET['delete'] == "single") {
$id = $_GET['id'];
$delete = ("DELETE FROM tagwall WHERE id ='$id'");
$delete_query = mysql_query($delete) or die (mysql_error());
echo "Besked med id-nummeret:<b>" . $id . "</b> blev slettet!
<meta http-equiv='refresh' content='1.5;url=tagwall.php'>";
} else {
if(isset($_SESSION['admin'])) {
echo "<a href=tagwall.php?delete=all>Slet alle</a><br><br>";
}
if($_POST['add'] == "post") {
$navn = $_POST['navn'];
$email = $_POST['email'];
$besked = $_POST['besked'];
$insert = ("INSERT INTO tagwall (navn, email, besked) VALUES ('$navn', '$email', '$besked')");
$insert_query = mysql_query($insert) or die(mysql_error());
}
$select = ("SELECT * FROM tagwall");
$select_query = mysql_query($select) or die(mysql_error());
$num_rows = mysql_num_rows($select_query);
if($num_rows == "0") {
echo "Der er ingen beskeder postet!";
}
while($row = mysql_fetch_array($select_query)) {
echo "<b>Skrevet af: <a href='mailto:" . $row[email] . "'>" . $row['navn'] . "</a></b>
<br>" . $row['besked'] . "<br>";
if(isset($_SESSION['admin'])) {
echo "<a href='tagwall.php?delete=single&id=" . $row[id] . "'>Slet</a><br><br>";
}
}
echo "<br><br><br>
<form method='post' action='" . $PHP_SELF . "'>
Navn: <input name='navn'><br>
Email: <input name='email'><br>
Besked:<br><textarea name='besked'></textarea><br>
<input type='submit' value='Post'>
<input type='hidden' name='add' value='post'>
</form>";
}
mysql_close($conn);
?>
tagwall.sql:
CREATE TABLE tagwall (
id int(8) NOT NULL AUTO_INCREMENT PRIMARY KEY,
navn varchar(20),
email varchar(60),
besked text
)
Indlæg senest redigeret d. 02.02.2007 16:17 af Bruger #8862