Code: Select all
<?PHP
$db = mysql_connect("localhost","******","******");
mysql_select_db ("******") or die ("Cannot connect to database");
$query = "INSERT INTO news(title, news, author, date)
VALUES('".$_POST['title']."','".$_POST['news']."','".$_POST['author']."', now())";
mysql_query($query);
echo "News Item Entered.";
mysql_close($db);
?>Code: Select all
<?php
$db = mysql_connect("localhost","******","******");
mysql_select_db ("******") or die ("Cannot connect to database");
#set the sql command as a variable
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 10";
#set the results
$result = mysql_query($query);
#take the results and echo them on the page as html for each returned record
while($r=mysql_fetch_array($result))
{
$title=$r["title"];
$news=$r["news"];
$author=$r["author"];
$date=$r["date"];
print "
<table width="200" border="0" cellspacing="1" cellpadding="1">
<tr>
<td class="style2 style1">News: $title</td>
</tr>
<tr>
<td class="style2 style1"><p>$news</p>
<p>Posted by: $author at $date</p></td>
</tr>
</table>
</br>";
}
#close the connection
mysql_close($db);
?>it will add in the image. same goes for links etc.
any ideas, ta