Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Calling random picure on forum home page  (Read 7205 times)

0 Members and 1 Guest are viewing this topic.

Pady

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
    • http://www.3dhost.co.uk
Calling random picure on forum home page
« on: October 09, 2003, 11:57:10 pm »

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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Calling random picure on forum home page
« Reply #1 on: October 10, 2003, 02:12:17 am »

take a look at the cpg-thumb mod (ssi.php) - maybe this'll help: http://prdownloads.sourceforge.net/coppermine/ssi.zip?download

GauGau
Logged

jasendorf

  • VIP
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 350
    • http://www.338tharmyband.com
Calling random picure on forum home page
« Reply #2 on: October 10, 2003, 03:59:47 am »

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

Code: [Select]

        $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>
Logged
Read the Online DOCs,FAQ, and SEARCH the board BEFORE posting questions for help.

Pady

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
    • http://www.3dhost.co.uk
Calling random picure on forum home page
« Reply #3 on: October 10, 2003, 10:15:30 am »

thanks guys, I will give it a go when i back this at the end of the weekend
Logged
Pages: [1]   Go Up
 

Page created in 0.014 seconds with 18 queries.