How can I make an argument if/else with the following. I would like to define the variable $condition as the intersection of Table A and Table B, and ultimately, where this condition is true, then execute some code.
Here is the PHP I have (I am trying to match up the table1.field1 and table2.field1 and where true, then I will add a CSS class to the <tr>)
$result = $dbh->query("SELECT field1, field2, field3, field4 FROM table1 ORDER BY field1 DESC");
$result->setFetchMode(PDO::FETCH_ASSOC);
$match = $dbh->query("SELECT table1.field1 FROM table1 INNER JOIN table2 WHERE table2.field1 = table1.field1");
$condition = **???????**
Also, is there a way to simplify this code? I feel like its too long. Mark Twain has a saying… “I’m sorry this letter is too long, I didn’t have time to make it shorter”. I wish I could say that this is relevant here, but I’ve been at this for a while! Any help would be greatly appreciated.
What about something like (in your first and then-only query)
(you should put backticks (
`) aroundmatch, since it’s a MySQL keyword)and in your loop