FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » isset not working with select
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: isset not working with select [message #181361 is a reply to message #181342] Mon, 13 May 2013 18:10 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 13/05/13 13:01, richard wrote:
> http://mroldies.net/showtable.php?year=1960
>
>
>
> $result = mysql_query("SELECT acover,bcover FROM A$year WHERE id =
> $number");
> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
> $cov = mysql_fetch_row($result);
>
>
> if (isset($cov[0]))
> {echo "<img src='http://mroldies.net/covers/$year/".$cov[0]."'>";}
> echo "<img src='http://mroldies.net/covers/$year/".$cov[1]."'>";
>
> On item #1 in the table, the panel appears with the desired images as
> wanted.
> On item #2 image place holders appear because I do not have them online
> yet.
> I do not want to see the place holders if there is not an image.
> What to use to do that?

isset() will not work in this case, as both cells will always be set.
I recommend you try empty() which will give you indication if the cell
is empty or not.

$value_to_use = empty($cov[0])?$cov[1]:$cov[0];
echo "<img src='http://mroldies.net/covers/$year/".$value_to_use."'>";


IMHO it's not good to echo things, build up what you want to do and echo
out everything when you are finished, this way you get out only what you
want to show to the user, as you can remove parts completely if they fail.


> Also, if you click on 1961, or any other year, and then any item in the
> table, you will get a message below the videos stating the column does not
> exist so it can't continue processing.
> How can I bypass this when that database does not have that column?

Don't know what you mean, didn't see any such message, but I guess that
is a question to a javascript newsgroup.


--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: mkdir no such file or directory
Next Topic: makes searching and booking applications airfares
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 23:51:15 GMT 2024

Total time taken to generate the page: 0.03932 seconds