Jump to content

[SOLVED] help with an if statement


marksie1988

Recommended Posts

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

<?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';

}
?>

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.