News:

CPG Release 1.6.29
During HTML5 upload, keep pseudo blank code 200 messages from triggering error condition
added Russian language
correct failure to use theme menu icons in album manager
minor vulnerabilities mitigation

Main Menu

Calling random picure on forum home page

Started by Pady, October 09, 2003, 11:57:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pady

Does anyone know how I would go about adding random pictures from the gallery onto my vbulletin forum homepage?

I would love to get this kind of integration into the forums so that it becomes more than just a button link.

thanks in advance

Pady

Joachim Müller


jasendorf

Here's something simple I did using ADObd for PHP.


        $connection = &ADONewConnection("mysql");
        $connection->PConnect( 'localhost' , 'EDITdbUSER' , 'EDITpasswordEDIT' , 'EDITCPGdatabaseEDIT' );
   
    $rs=$connection->Execute("SELECT aid, filepath, filename, caption FROM cpg11d_pictures WHERE aid = 2 OR aid = 6"); //edit to include those albums you wish to include
        if (!$last_row) {
                echo $connection->ErrorMsg();
   }
   $total_matches=$rs->RecordCount();
   
        //seed the random number generator
        mt_srand((double)microtime()*1000000);
   
        $rand_max = $total_matches;
        $rand_max--;
   
        //get a random number
        $rand_image = mt_rand(0 , $rand_max);

        //match random number with a URL and assign it a string value
    $rs->Move($rand_image);

        //use results to create a image URL string
        $rand_image_url = "photo_gallery/albums/" . $rs->fields[1] . "normal_" . $rs->fields[2];
   
    $caption = $rs->fields[3];
    $alt_text = $caption;

?>
<p align="center"><a href="photo_gallery" border=0><img src="<?PHP echo $rand_image_url;?>" alt="<?PHP echo $alt_text;?>.
Click here to view more images." border="0"></a><br><b><font size=-2><?PHP echo $alt_text;?></font></b></p>
Read the Online DOCs,FAQ, and SEARCH the board BEFORE posting questions for help.

Pady

thanks guys, I will give it a go when i back this at the end of the weekend