farawayman
asked on
Record Set - Show Field If Contains Data
Hi,
I have a dynamic table (DW) which displays a recordset. There is a field (lets say image) and if there is a value in this field then I want to diplay a checkbox with a tick in.
Hope thats clear!
Thanks,
Farawayman
I have a dynamic table (DW) which displays a recordset. There is a field (lets say image) and if there is a value in this field then I want to diplay a checkbox with a tick in.
Hope thats clear!
Thanks,
Farawayman
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Squinky,
I went for this:
<tr class=table_emphasis><td>A ttached File Name</td></tr>
<tr><td><?php if ($row_rs_requestdetail['fi le_id'] == "") { // Show if recordset field empty ?>
No Attached File Found
<?php } // Show if recordset empty ?> <?php if ($row_rs_requestdetail['fi le_id'] != "") { // Show if recordset field not empty ?>
<?php echo $row_rs_requestdetail['fil e_id']; ?>
<?php } // Show if recordset field not empty ?> </td></tr>
<?php } while ($row_rs_requestdetail = mysql_fetch_assoc($rs_requ estdetail) ); ?>
</table>
Changed a bit of DW stuff - but this doesn't do for the checkbox but I think I can figure it from here.
I went for this:
<tr class=table_emphasis><td>A
<tr><td><?php if ($row_rs_requestdetail['fi
No Attached File Found
<?php } // Show if recordset empty ?> <?php if ($row_rs_requestdetail['fi
<?php echo $row_rs_requestdetail['fil
<?php } // Show if recordset field not empty ?> </td></tr>
<?php } while ($row_rs_requestdetail = mysql_fetch_assoc($rs_requ
</table>
Changed a bit of DW stuff - but this doesn't do for the checkbox but I think I can figure it from here.
OK, that looks fair enough - just add a checkbox input tag - I was assuming you wanted to display the box checked if there was a file and unchecked if it wasn't, rather than present and checked, or entirely absent.
Using a bottom-tested while loop here is untidy - you'll get a warning when accessing $row_rs_requestdetail['fil e_id'] if no records were found (when it displays 'no attached file found') because the "file_id" index won't exist.
BTW, your code might be a bit more readable if you use this syntax when mixing PHP and content:
http://uk.php.net/manual/en/control-structures.alternative-syntax.php
I don't like this syntax, but it's better than nothing if you're not using Smarty.
Using a bottom-tested while loop here is untidy - you'll get a warning when accessing $row_rs_requestdetail['fil
BTW, your code might be a bit more readable if you use this syntax when mixing PHP and content:
http://uk.php.net/manual/en/control-structures.alternative-syntax.php
I don't like this syntax, but it's better than nothing if you're not using Smarty.
ASKER
what is smarty?
A very nice PHP templating system: http://smarty.php.net/
SELECT blobdata, 1 <=> blobdata FROM table WHERE id='1'