![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi guys and thanx so long for your help. DW CS3, PHP & mySql. I have a database with two fields for images; image_1 and image_2 It so happens that many of the records don't have an image_2 in the DB and some have no images at all. How do I need to tweak the code so that no error or place holder is shown. If there is an image, it must show the image and if there is no image, no place holder or error message must show. I don't want to have an image that says "No Image Available". |
#3
| |||
| |||
|
|
?php echo isset($row_myRecordset['image1']?"<img src='" . $row_myRecordset['image1'] . "alt='my image'>":''; ? ?php echo isset($row_myRecordset['image2']?"<img src='" . $row_myRecordset['image2'] . "alt='my other image'>":''; ? |
#4
| |||
| |||
|
|
Hopefully you're just storing an image name, and not the image itself, in the database? ?php echo isset($row_myRecordset['image1']?"<img src='" . $row_myRecordset['image1'] . "alt='my image'>":''; ?> <?php echo isset($row_myRecordset['image2']?"<img src='" . $row_myRecordset['image2'] . "alt='my other image'>":''; ? http://www.php.net/operators.comparison#language.operators.comparison .t ernary Hi Joe. |
#5
| |||
| |||
|
|
Missed a parenthesis, two places, just before the question mark: ?php echo isset($row_myRecordset['image1'])?"<img src='" . $row_myRecordset['image1'] . "alt='my image'>":''; ?> <?php echo isset($row_myRecordset['image2'])?"<img src='" . $row_myRecordset['image2'] . "alt='my other image'>":''; ? |
#6
| |||
| |||
|
|
this is what I have: ?php echo isset($row_rsResults['prod_image1'])?"<img src='" . row_rsResults['prod_image1'] . "alt='my image'>":''; ? Now there is only a place holder and no image. I have double checked my Recordset and the field name in the DB. Anything else I can check? |
#7
| |||
| |||
|
|
Missed a parenthesis, two places, just before the question mark: ?php echo isset($row_myRecordset['image1'])?"<img src='" . $row_myRecordset['image1'] . "alt='my image'>":''; ?> <?php echo isset($row_myRecordset['image2'])?"<img src='" . $row_myRecordset['image2'] . "alt='my other image'>":''; ? Joe, this is what I have: ?php echo isset($row_rsResults['prod_image1'])?"<img src='" . row_rsResults['prod_image1'] . "alt='my image'>":''; ? Now there is only a place holder and no image. I have double checked my Recordset and the field name in the DB. |

#8
| |||
| |||
|
|
On 04 Apr 2009 in macromedia.dreamweaver, Deon H wrote: this is what I have: ?php echo isset($row_rsResults['prod_image1'])?"<img src='" . row_rsResults['prod_image1'] . "alt='my image'>":''; ? Now there is only a place holder and no image. I have double checked my Recordset and the field name in the DB. Anything else I can check? Change isset to !empty and see if that works: echo !empty($row_rsResults['prod_image1'])?... |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
Hi all. with this: ?php echo isset($row_rsResults['prod_image1']) ? '<img "src=' . $row_rsResults['prod_image1'] . '" alt="my image">' : ''; ? |

![]() |
| Thread Tools | |
| Display Modes | |
| |