Jump to content

[SOLVED] if else...the bain of my existance! Grrr....hehe


NoDoze

Recommended Posts

if (isset($row['murl']))
echo "<a href=".$row['murl'] . ">more info</a>";
else
echo "<a href=".$row['mhover'] . ">more info</a>";

 

I think this is correct....but if the variable isn't present, it's NOT showin the mhover URL....what am I doing wrong?

 

I'm trying to do...

 

If variable is pesent in DB

do THIS

ELSE

Do THAT

 

Thanks!

Link to comment
Share on other sites

as ken2k7 noted, as long as you select the column $rows['murl'] will always be set. you need to know its value. try using is_null and empty. something like...

 

if (is_null($row['murl']) || empty($row['murl'])) {
  ...
} else {
  ...
}

Link to comment
Share on other sites

First of all if is_null($var) is true, then empty($var) is true. There's no need to call both, especially when it's an OR statement.

 

yep. just re-read the man page for empty. sum-bitch. been coding redundancy into my first php app already. :) thanks for the info. gonna have to fix that in the next iteration.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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