graham23s Posted January 31, 2010 Share Posted January 31, 2010 Hi Guys, What i'm trying to do is pull from and xml file and loop from the database, if 2 codes match then perform an action. code: <?php include("inc/inc-dbconnection.php"); $call_url = 'http://www.site.com/load_xml.php?id=15320&subid=&geoip='.$user_ip; $xml = simplexml_load_file($call_url); //START Simple Output foreach($xml->offer as $offers) { $c1 = $offers->country; $q = mysql_query("SELECT * FROM `cpa_country_codes`"); while ($r = mysql_fetch_array($q)) { $c2 = $r['code_country']; if ($c1 == $c2) { //Perform action } } } ?> This is what i have concocted so far. any help would be appreciated thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/190443-matching-xml-data-to-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 31, 2010 Share Posted January 31, 2010 You are missing one of the main points of using a database, let the database engine find the data you want. You should be using a WHERE clause in your query and then testing if the query returned a matching row. Your query should be something like this - "SELECT * FROM cpa_country_codes WHERE code_country = '$c1'" Quote Link to comment https://forums.phpfreaks.com/topic/190443-matching-xml-data-to-database/#findComment-1004594 Share on other sites More sharing options...
graham23s Posted January 31, 2010 Author Share Posted January 31, 2010 Hi Mate, ahh that worked great! can't believe i miseed that one cheers Graham Quote Link to comment https://forums.phpfreaks.com/topic/190443-matching-xml-data-to-database/#findComment-1004598 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.