I have multiple columns withing my mysql data base however I need data from 1 of 2 of them. There is either data in column1 or column2 there is no insane where data is available in both.
I have tried the below with no luck. I have also looked around and can't seem to find an easy way of dealing with this.
<?php
$query = "SELECT `column1`,`column2` FROM `table` WHERE `name` LIKE 'Jack'";
$columcheck = $query['column1'];
if ($columcheck == null) {
$columcheck = $query['column2'];
}
echo $columcheck;
?>
I basically just want to echo the column that is not empty.
Thanks in advance. Lucas.