[問題]在論壇首頁顯示CPG的隨機圖片
發表於 : 2004-05-30 11:16
請問各位大大有沒有一些能在在論壇首頁上顯示CPG的隨機圖片的MOD呢?
代碼: 選擇全部
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" height="25"><span class="genmed"><b>隨機圖片</b></span></td>
</tr>
<tr>
<td class="row1" align="center">
<?php
//<?php
//***Enter Path information here***
//***absolute path to main coppermine directory***
$copperminepath = './gallery'; //***YOU MUST CHANGE THIS***
//This connects to the mysql DB
//***change username and password below***
$MZrandompic = @mysql_connect('localhost', 'root', 'password'); //***YOU MUST CHANGE THIS***
if (!$MZrandompic) {
echo( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
exit();
}
//select photo DB
//***YOU MUST CHANGE THIS***
if (! @mysql_select_db('dbname') ) {
die( '<p>Unable to locate the picture ' .
'database at this time.</p>' );
}
//This gets a random picture record from the database and
//the picture's location and displays it
$MZresult = @mysql_query("SELECT * FROM cpg133_pictures ORDER BY RAND() LIMIT 0,4");
if (!$MZresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZrow = mysql_fetch_array($MZresult) ) {
//$albumid = $MZrow['aid']; //This gets the picture's associated album name
$pos = $MZrow['pid']; //This finds the picture's coppermine location
$filepath = $MZrow['filepath'];
$filename = $MZrow['filename'];
//echo('<P ALIGN=center>');
echo('<a href="' . $copperminepath . '/displayimage.php?album=' . $albumid .
'&pos=-' . $pos . '">'); //make thumbnail clickable
echo('<IMG SRC="' . $copperminepath . '/albums/'); //append base dir structure
echo( $filepath .normal_. $filename .
'" alt=' . $MZrow['title'] . ' '. 'border=0 height=150></a> '); //outputs path from /userspics
}
//This displays the picture's album name and
//links it to the coppermine album
$MZalbumresult = @mysql_query("SELECT * FROM cpg133_albums WHERE aid = '$albumid'");
if (!$MZalbumresult) {
die('<p>Error performing query: ' . mysql_error() .
'</p>');
}
while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {
echo('<P ALIGN=center>');
echo('<a href="' . $copperminepath .
'/thumbnails.php?album=' . $albumid . '">' .
$MZalbumname['title'] . '</a>' . '</p>');
}
if (! @mysql_select_db('dbname) ) {
die( '<p>Unable to reload the main website ' .
'database at this time.</p>' );
}
//?>
</td>
</tr>
</table>