Hi folks and an advanced thank you for reading this to try to understand my problem. A double thanks if you can help!
I am trying to return an absolutely unique 5x4 array populated from random database retrieves.
eg (my script so far)
function getImage($cc) {
//get Image
$selectI = mysql_query("SELECT * FROM images WHERE country LIKE '$cc' ORDER BY RAND() LIMIT 1");
$getI = mysql_fetch_row($selectI);
$image = $getI['place'];
return $image;
}
function getCountry($cc) {
//get Country area
$selectP = mysql_query("SELECT * FROM places WHERE country LIKE '$cc' ORDER BY RAND() LIMIT 1");
$getP = mysql_fetch_row($selectP);
$place = $getP['place'];
return $place;
}
function getBlurb($cc) {
//get country_specific blurb
$selectB = mysql_query("SELECT * FROM blurbs WHERE country LIKE '$cc' ORDER BY RAND() LIMIT 1");
$getB = mysql_fetch_row($selectB);
$blurb = $getB['blurb'];
return $blurb;
}
function getHandle($lang) {
//get a random handle
$selectL = mysql_query("SELECT * FROM handles WHERE language LIKE '$lang' ORDER BY RAND() LIMIT 1");
$getL = mysql_fetch_row($selectL);
$handle = $getL['handle'];
return $handle
}
//produce the array
$adnum = 0;
$numads = 5;
for($y=0; $y<$numads; $y++) {
$ad[$adnum]['image'] = getImg($y);
//ad unique check here
$ad[$adnum]['country'] = getCountry($cc);
//ad unique check here
$ad[$adnum]['blurb'] = getBlurb($cc);
//ad unique check here
$ad[$adnum]['handle'] = getHandle($lang);
//ad unique check here
}
What I want to do is wherever there's a
//ad unique check here
I want some sort of function to then go off and search the array $ad (every dimension) to make sure the bit that has been returned does not occur anywhere in the ad array.
Thanks in advance for any and all help
---edit
I have to add, and this is where I'm falling a cropper, is whatever function checks for a in_array() has to be reitereative ie, if the first return from the function is not unique, then relaunch the array again and then check that to make sure it's unique...if not relaunch again...and again. This reiterative check is what I'm actually stuck on!