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 Link to comment https://forums.phpfreaks.com/topic/77540-solved-help-with-an-if-statement/ 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 Link to comment https://forums.phpfreaks.com/topic/77540-solved-help-with-an-if-statement/#findComment-392499 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/77540-solved-help-with-an-if-statement/#findComment-392505 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 Link to comment https://forums.phpfreaks.com/topic/77540-solved-help-with-an-if-statement/#findComment-393038 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); Link to comment https://forums.phpfreaks.com/topic/77540-solved-help-with-an-if-statement/#findComment-393149 Share on other sites More sharing options...
marksie1988 Posted November 19, 2007 Author Share Posted November 19, 2007 *BUMP* Link to comment https://forums.phpfreaks.com/topic/77540-solved-help-with-an-if-statement/#findComment-394533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.