I Need Random Link Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    I Need Random Link Script

    hello guys can any one give me a Random Link Scripts

    #2
    erm use random image script but instead of the <img. tags replace with <a href> tags lol a noob could do that in 2 mins









    Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..
    Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free

    Comment


      #3
      This function returns a random file from a given folder. It also allows extension filtering.
      PHP Code:
      function RandomFile($folder='', $extensions='.*'){ 
        
          // fix path: 
          $folder = trim($folder); 
          $folder = ($folder == '') ? './' : $folder; 
        
          // check folder: 
          if (!is_dir($folder)){ die('invalid folder given!'); } 
        
          // create files array 
          $files = array(); 
        
          // open directory 
          if ($dir = @opendir($folder)){ 
        
              // go trough all files: 
              while($file = readdir($dir)){ 
        
                  if (!preg_match('/^.+$/', $file) and  
                      preg_match('/.('.$extensions.')$/', $file)){ 
        
                      // feed the array: 
                      $files[] = $file;                 
                  }             
              }         
              // close directory 
              closedir($dir);     
          } 
          else { 
              die('Could not open the folder "'.$folder.'"'); 
          } 
        
          if (count($files) == 0){ 
              die('No files where found :-('); 
          } 
        
          // seed random function: 
          mt_srand((double)microtime()*1000000); 
        
          // get an random index: 
          $rand = mt_rand(0, count($files)-1); 
        
          // check again: 
          if (!isset($files[$rand])){ 
              die('Array index was not found!'); 
          } 
        
          // return the random file: 
          return $folder . $files[$rand]; 
        
      } 
      
      Get a random row from a table. Useful for just about anything where you need a random entry. Put in anything you want, but just leave \"ORDER BY RAND()\" and \"LIMIT n\" where they are. (LIMIT can be set to any number you want though.) [/B][/B]



      SELECT * FROM `sometable` WHERE 1 ORDER BY RAND() LIMIT 1;



      This will show a random link when someone comes to your page.


      //set the urls
      $urls = array("http://google.com" ,"http://hotmail.com" ,"http://hawkee.com" );

      //set the text links
      $text = array("Google" ,"Hotmail" ,"Hawkee");
      srand(time());

      //set the number in (rand()%3); for however many links there are
      $random = (rand()%3);
      echo ("<a href = \"$urls[$random]\">$text[$random]</a>");



      Or see attach:
      Attached Files
      http://ngeo.ro

      Comment

      Working...
      X