marksie1988 Posted November 15, 2007 Share Posted November 15, 2007 i am trying to create an if statement which basically says if ('order' in table1 == 'order' in table2){ echo data } else{ dont echo data } i dont have a clue how to compare 2 tables like this help appreciated or a point in the right direction Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 15, 2007 Share Posted November 15, 2007 are you asking for SQL statement or what ? explain it better Quote Link to comment Share on other sites More sharing options...
Asperon Posted November 16, 2007 Share Posted November 16, 2007 <?php $query = "SELECT order1 FROM table1 WHERE something='condition' LIMIT 1"; //this is your mysql statement that will get your order1 info $result = mysql_query($query) or die('Query Failed: '.mysql_error()); $order1 = mysql_result($result,0); $query = "SELECT order2 FROM table2 WHERE something='condition' LIMIT 1"; //this is your mysql statement that will get your order2 info $result = mysql_query($query) or die('Query Failed: '.mysql_error()); $order2 = mysql_result($result,0); if($order1 == $order2){ echo 'We are the same'; } else{ echo 'We are not the same'; } ?> Quote Link to comment Share on other sites More sharing options...
marksie1988 Posted November 16, 2007 Author Share Posted November 16, 2007 ok i intergrated the code but i get this error Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 21 in /home/******/public_html/blacklime/track/index.blc on line 54 Quote Link to comment Share on other sites More sharing options...
marksie1988 Posted November 16, 2007 Author Share Posted November 16, 2007 here is the code where the problem is if this helps $id = $_POST['on']; $query = "SELECT `on` FROM `track_website` WHERE `on`='".$id."' LIMIT 1"; //this is your mysql statement that will get your order1 info $result = mysql_query($query) or die('Query Failed: '.mysql_error()); $order1 = mysql_result($result, 0); $query = "SELECT `order` FROM `track_website_post` WHERE `order`='".$id."' LIMIT 1"; //this is your mysql statement that will get your order2 info $result = mysql_query($query) or die('Query Failed: '.mysql_error()); $order2 = mysql_result($result, 0); Quote Link to comment Share on other sites More sharing options...
marksie1988 Posted November 19, 2007 Author Share Posted November 19, 2007 *BUMP* Quote Link to comment 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.