Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #9306
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: isset not working with select |
| Date | 2013-05-13 20:10 +0200 |
| Message-ID | <avcokgFb7ihU1@mid.individual.net> (permalink) |
| References | <zjgov1oukrit$.nu30chb74ox5.dlg@40tude.net> |
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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
isset not working with select richard <noreply@example.com> - 2013-05-13 07:01 -0400
Re: isset not working with select Scott Johnson <noonehome@chalupasworld.com> - 2013-05-13 05:49 -0700
Re: isset not working with select "Peter H. Coffin" <hellsop@ninehells.com> - 2013-05-13 07:43 -0500
Re: isset not working with select The Natural Philosopher <tnp@invalid.invalid> - 2013-05-13 23:31 +0100
Re: isset not working with select "J.O. Aho" <user@example.net> - 2013-05-13 20:10 +0200
Re: isset not working with select The Natural Philosopher <tnp@invalid.invalid> - 2013-05-13 23:43 +0100
Re: isset not working with select Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-13 19:54 +0000
Re: isset not working with select richard <noreply@example.com> - 2013-05-14 17:38 -0400
Re: isset not working with select richard <noreply@example.com> - 2013-05-15 16:23 -0400
Re: isset not working with select Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-15 20:34 +0000
Re: isset not working with select richard <noreply@example.com> - 2013-05-15 17:07 -0400
Re: isset not working with select Christoph Becker <cmbecker69@gmx.de> - 2013-05-15 23:18 +0200
Re: isset not working with select richard <noreply@example.com> - 2013-05-15 19:07 -0400
Syntax Highlighting (was: isset not working with select) Christoph Becker <cmbecker69@gmx.de> - 2013-05-16 01:33 +0200
Re: isset not working with select Tim Streater <timstreater@greenbee.net> - 2013-05-16 08:27 +0100
Re: isset not working with select richard <noreply@example.com> - 2013-05-15 17:12 -0400
Re: isset not working with select Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-15 23:54 +0000
Re: isset not working with select Tim Streater <timstreater@greenbee.net> - 2013-05-15 22:15 +0100
csiph-web