Jump to content

How to find record in array that meets multiple comparisons


brentman
Go to solution Solved by brentman,

Recommended Posts

I am building a bid function that will display the best available ad inventory to the current user.
 
I have a record for user like so:
 
$user_record = interest, gender, country
 
I am then pulling all available records to array for available ad inventory to find all eligible ads:
 
$ad_array = budget, interest, gender, country (for a whole table)
 
So I want to only pull those with remaining budget (ie like $budget>$.50), if interest is set, only if interest = interest, if gender is set, only if gender = gender, if country is set, only if country=country
 
Now there may be 1 or there may be 20 or more ad campaigns in the array. But I want to remove the ones that do not fit certain rules.
 
//GETS THE USER RECORD
$result = mysql_query("SELECT user_record FROM usertable WHERE user_record = '$user_record'");
$row = mysql_fetch_row($result);

//GETS ALL AD CAMPAIGNS
$query = "SELECT * FROM campaigns";
$result = mysql_query($query);

//MAKES ARRAY FOR ONLY ELIGIBLE CAMPAIGNS
?????

So what code to I put for the ?????? that will remove ad campaigns that are not eligible, leaving only eligible campaigns in the array?

Edited by brentman
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.