Ja altså..
Her laver jeg min nye artikel:
<?php include ("_header.php"); ?>
<div id="page_wrap">
<form id="test_form" name="test_form" method="post" action="<?php echo $PHP_SELF; ?>">
<table width="503" border="0">
<tr>
<td width="497"><br /><span class="artikel_overskrift_form">Skriv ny artikel</span><br /><br />
</td>
</tr>
<tr>
<td>Dit navn:</td>
</tr>
<tr>
<td><input type="text" name="af" id="af" value="brianzet" class="input-fields" />
<br /><br /></td>
</tr>
<tr>
<td>Navn på artiklen: </td>
</tr>
<tr>
<td><input type="text" name="navn" id="navn" class="input-fields" />
<br /><br /></td>
</tr>
<tr>
<td>Beskrivelse af artiklen:</td>
</tr>
<tr>
<td><textarea name="beskrivelse" id="beskrivelse" rows="5" class="message-fields"></textarea>
<br /><br /></td>
</tr>
<tr>
<td>Artiklen:</td>
</tr>
<tr>
<td><textarea name="artikel" id="artikel" rows="15" class="message-fields"></textarea>
<br /><br /></td>
</tr>
<tr>
<td align="right"><input type="submit" name="Submit" class="btn" id="Submit" value="OPRET ARTIKEL" /><br /><br /></td>
</tr>
</table>
</form>
<?php
mysql_connect("localhost", "", "");
mysql_select_db("webeliten_dk");
$af = $_POST['af'];
$navn = $_POST['navn'];
$beskrivelse = $_POST['beskrivelse'];
$artikel = $_POST['artikel'];
$date = date("M d. Y");
if($_POST['Submit'])
{
mysql_query("INSERT INTO artikler (af, navn, artikel, date, beskrivelse) VALUES ('$af','$navn','$artikel','$date', '$beskrivelse')")
OR DIE(mysql_error());
echo ("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=artikler.php\">
");
}
else
{
/* echo ("Der opstod en fejl."); */
}
mysql_close();
?>
</div>
<?php include ("_footer.php"); ?>
Her vises beskrivelse på forsiden:
<?php include ("_header.php"); ?>
<div id="page_wrap">
<div id="outer_artikel_out">
<?php
//Include the PS_Pagination class
include('ps_pagination.php');
//Connect to mysql db
$conn = mysql_connect('localhost','','');
mysql_select_db('webeliten_dk',$conn);
$sql = 'SELECT * FROM artikler ORDER BY id DESC';
//Create a PS_Pagination object
$pager = new PS_Pagination($conn,$sql,5,5);
//The paginate() function returns a mysql result set
$rs = $pager->paginate();
while($row = mysql_fetch_array($rs)) {
echo nl2br ("<div id=\"artikel_out\"><span class=\"headliner\"><a href=\"laes_artikel.php?laes_artikel={$row['id']}\">{$row['navn']}</a></span><br /><br />
<span class=\"skrevet_af\"><b>{$row['date']}</b> by <b>{$row['af']}</b></span>
<br/><br/><span class=\"beskrivelse\">{$row['beskrivelse']}</span><br /><br /><a href=\"laes_artikel.php?laes_artikel={$row['id']}\">Read more...</a><br /><br /></div>");
}
?>
<br /><br />
<?php
//Display the link to first page: First
echo $pager->renderFirst();
//Display the link to previous page: <<
echo $pager->renderPrev();
//Display page links: 1 2 3
echo $pager->renderNav();
//Display the link to next page: >>
echo $pager->renderNext();
//Display the link to last page: Last
echo $pager->renderLast();
echo ("<br /><br /><br /><br />");
?>
</div>
<div id="right_sidebar"></div>
</div>
<?php include ("_footer.php"); ?>
Og her læses hele artikel:
<?php include ("_header.php"); ?>
<div id="page_wrap">
<?php
include ("config.php");
$db_laes_artikel = mysql_query("SELECT * FROM artikler WHERE id = '$_GET[laes_artikel]'");
$laes_artikel = mysql_fetch_array($db_laes_artikel);
?>
<h2><?php echo nl2br ("{$laes_artikel['navn']}"); ?></h2>
<br />
<?php echo nl2br ("{$laes_artikel['artikel']}"); ?>
<br />
<br />
Skrevet den: <?php echo ("{$laes_artikel['date']}"); ?> af: <?php echo ("{$laes_artikel['af']}"); ?>
</div>
<?php include ("_footer.php"); ?>