Search & Compare Multiple MySQL Tables -
i'm trying use php search ips , ad networks in mysql database. rotate visitors between various ad networks prevent same visitor being sent same network within 24 hour period.
ip_addresses table
id, address, network_id 1, 120.110.140.223, 1 2, 120.110.140.223, 3 3, 115.157.247.46, 1 networks table
id, name, clicks, status, order 1, random name, 200, active, 1 2, example name, 500, inactive, 3 3, other name, 100, active, 2 basically when visitor hits our php page, need able echo specific id networks table. should the id of first network isn't listed in ip_addresses table visitor's ip address. networks should ordered order column , should have status = active.
i thought using php list of id's of networks status set active , correctly ordered this:
select id networks status = 'active' order id asc and loop through until reach first id isn't in ip_addresses table ip. however, wasn't sure how loop or how make stop once first network_id isn't in ip_addresses table found.
if need clarify anything, please let me know. thanks!
you use not in sub-query passing user's ip
select id networks status = 'active' , id not in ( select network_id ip_addresses address = '$ip' ) order id limit 1;
Comments
Post a Comment