<?php
// set your database infomation.
include("config.php");
// connect to the mysql database server.
$connect = mysql_connect($dbhost, $dbusername, $dbuserpass);
// select the database
mysql_select_db($dbname, $connect);
// Retrieve all the data from the "tutorials" table
$sql = "SELECT * FROM news";
$result = mysql_query( $sql );
// this gets the next row until there are no more to get
if( mysql_query( $sql ) ){
?>
<table width="100%">
<tr>
<th width="100%" colspan="2">Admin Section - News</th>
</tr>
<?php
while($row = mysql_fetch_array( $result )) {
?>
<tr>
<td colspan="2">
<h3><?php echo $row['title']; ?></h3><br />
<?php echo $row['news']; ?><br />
<small>Created: <?php echo $row['date']; ?></small><br />
</td>
</tr>
<tr>
<td width="50%" align="center"><a href="edit.php?news_title=<?php echo $row['title']; ?>">EDIT THIS ENTRY</a></td>
<td width="50%" align="center"><a href="delete.php?news_title=<?php echo $row['title']; ?>">DELETE THIS ENTRY</a></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
echo "No News - If this seems to be a mistake, please contact <a href='mailto:[email protected]?subject=News%20Script'>the webmaster</a><br /><br />";
die(mysql_error());
}
?>