For some reason this always goes to else, there are fields in my database which are empty so im not sure why its not working.
Am i doing it the right way?
echo $row." Worktop";
echo “<a href='”. $row .“'>”. $row." Worktop</a>";
Here is a good article on Isset and empty.
Thanks guys, will give the above a try when i get home. the field is set a varchar in my db
if (!isset($row[13) || !trim($row))
if entity from db is empty you get result and $row is set, try to do it this way
- var_dump($row) - so you can see value of all elements of an array, and if $row is empty you can then check it this way
I hope this helps
I am not sure what is the data type of the field/column in the database. Sometimes there might be some spaces or sometimes unknowingly new line characters may exist in the field which means the field is set. So use trim the value and then use empty instead of isset.
I’m guessing $row comes from something such as mysql_fetch_row, or $mysqli->fetch_row().
In that case, you’ll want to use !empty() instead of isset(). It may not hurt to include a call to trim() like poops mentioned.