00squeaky -
Joined: 11 May 2004 Posts: 60
|
Posted: Tue Jul 13, 2004 3:02 am Post subject: News column PHP script |
|
|
so, i know alot of you want a news script without having to get PHPBB2, or the portal thingy. this code pull out news from a database, and formats the information into a nice newsbox.
so, here is the withdrawl code.
Code: |
//make sure you have a table in your DB named news, with columns;
//id,title,text,author,subject,date.
//copyright 00squeaky 2004
$link = mysql_connect('xxx.xxx.xxx.xxx','mysql username','mysql password');
$db = mysql_select_db('your database name',$link);
$sql=("SELECT * FROM news");
$result=mysql_query($sql);
$numrows=mysql_num_rows($result');
//this determines the number of newsboxes to display
if ($numrows > 10) {
$rowdisp = 10
}
for ($i=$numrows; $i >= 1; $i--) {
$sql=("SELECT * FROM news where id='".$i."'");
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);
echo "<table cellspacing=0 border=0 cellpadding=0>
<tr>
<td background=\"pix/lborder.jpg\" width=20 height=20></td>";
echo "<td background=\"pix/tborder.jpg\" width=300 height=20> $newscol[title] </td>";
echo "</tr><tr><td bgcolor=\"#8585FF\"></td>
<td height=20 bgcolor=\"#BBBBBB\" valign=top><font size=2>$newscol[date] | $newscol[author] | $newscol[subject]</font>
</td></tr>";
echo "<tr>
<td bgcolor=\"#8585FF\"></td>
<td bgcolor=\"#F1F1F1\">
$newscol[text]
<BR><img src=\"pix/watermark.gif\"><b>GGzone</b>
</td>
</tr>
</table>";
echo "<p>";
}
|
images you can make:
lborder.gif (a corner image)
tborder.gif (an along top image)
watermark.jpg (your site logo)
okay, that is all, just customize a few things. _________________ Languages mastered:
HTML,GML,C,PHP,MYSQL (not really a language, but wtf) |
|