Re: isset not working with select [message #181373 is a reply to message #181346] |
Mon, 13 May 2013 22:31 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 13/05/13 13:43, Peter H. Coffin wrote:
> On Mon, 13 May 2013 07:01:46 -0400, 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?
> If the first one works and the second one doesn't, maybe you should just
> do them both like the first one?
>
>> 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?
> Again, check for zero rows being returned in your program and build code
> to handle that circumstance. die() is NOT your friend.
>
if (mysql_numrows($result)) // there is some date to process
....
else
// there isn't.
....
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
|
|
|