News column PHP script

 
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials
View previous topic :: View next topic  

was this usefull to you?
yes
40%
 40%  [ 2 ]
no
60%
 60%  [ 3 ]
errors in the code
0%
 0%  [ 0 ]
Total Votes : 5

Author Message
00squeaky
-


Joined: 11 May 2004
Posts: 60

PostPosted: Tue Jul 13, 2004 3:02 am    Post subject: News column PHP script Reply with quote

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> &nbsp; $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)
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group