Return to Snippet

Revision: 52173
at October 15, 2011 02:06 by flatearthcomms


Initial Code
extract($_REQUEST);
	
	$sql = "SELECT * FROM `site` WHERE `id`='1' ";
	$result = doSQL($sql);
	$r=mysql_fetch_array($result);
	extract($r);

	$sqlBG = " SELECT `bgFile` FROM `site_bgs` AS r1 JOIN
       (SELECT (RAND() *
                     (SELECT MAX(bgID) FROM random)) AS id)
        AS r2
 WHERE r1.id >= r2.id
 ORDER BY r1.id ASC
 LIMIT 1;	";
 
 
	$range_sql = " SELECT MAX(`bgID`) AS max_id , MIN(`bgID`) AS min_id FROM `site_bgs` " ;
	$range_result = doSQL($range_sql);
	$range_row = mysql_fetch_object( $range_result ); 
	$random = mt_rand( $range_row->min_id , $range_row->max_id );




	// Special code for Jane to test backgrounds
	if ( isset($bg) ) {

		$sqlBG = " SELECT * FROM `site_bgs` WHERE `bgID`='$bg' ";

	
	} else {

		$sqlBG = " SELECT * FROM `site_bgs` WHERE `bgID` >= $random LIMIT 0,1 ";

 	}


	$resultBG = doSQL($sqlBG);
	$rBG=mysql_fetch_array($resultBG);
	$bg = $rBG['bgFile'];

Initial URL

                                

Initial Description

                                

Initial Title
Pick random field vale from mySQL (image filename etc)

Initial Tags

                                

Initial Language
PHP