Thread: PHP Problem
View Single Post
01-07-2007, 07:32 PM
#6
Paris Holley is offline Paris Holley
Status: Member
Join date: Dec 2005
Location:
Expertise:
Software:
 
Posts: 347
iTrader: 0 / 0%
 

Paris Holley is on a distinguished road

  Old

try this

PHP Code:
<?php
$rel 
"forum/"// The directory to your forum--relative to this file's location; include ending slash
chdir($rel);
$host "localhost"// Your database host
$user "****"// Your database username
$pass "***"// Your database password
$data "wiiroom_board"// The name of your database
$prfx "mybb_"// The table prefix of your database
$col1 "#FFFFFF"// The color of the first row--alternating row colours
$col2 "#FCFCFC"// The color of the second row
// NOTE: I didn't include ./global.php because I wasn't sure what the variables look like.
$num 5// The number of recent posts to show
$author TRUE// Should we display the post author? (TRUE or FALSE)

$conn mysql_connect($host,$user,$pass) or die("<b>Error:</b> Database connection failed.");
$sel mysql_select_db($data,$conn) or die("<b>Error:</b> Database connection failed.");

if(
$author == TRUE)
{
?>
<table>
<?php
}
$i 0;
$q mysql_query("SELECT p.*,f.* FROM ".$prfx."posts p LEFT JOIN ".$prfx."forums f on f.fid=p.fid ORDER BY p.dateline DESC LIMIT ".$num);
while(
$row mysql_fetch_array($q))
{
 if(
$i == 0)
 {
  
$bgcolor $col1;
 }
 else
 {
  
$bgcolor $col2;
 }
 
$i++;
?>
 <tr>
  <td width="50%" bgcolor="<?php echo $bgcolor?>">
<a title="In forum: <?php echo $row["name"]; ?>" href="<?php echo $rel?>showthread.php?tid=<?php echo $row["tid"]; ?>&action=lastpost">
<b><?php echo $row["subject"]; ?></b></a></p></td>
<?php
 
if($author == TRUE)
 {
?>
  <td width="50%" bgcolor="<?php echo $bgcolor?>">by 
<b><a title="<?php echo $row["username"]; ?>'s Profile" href="<?php echo $rel?>member.php?action=profile&uid=<?php echo $row["uid"]; ?>">
<?php echo $row["username"]; ?></b></a></td>
<?php
 
}
?>
 </tr>
<?php
}
?>
</table>
^updated