A JM Posted August 20, 2009 Share Posted August 20, 2009 Is there a way to disable a image link on my page if the resultset from a Mysql query returns zero rows? Maybe there is a better way to do this instead of testing the resultset is equal to zero, any other ideas or suggestions? Thanks, A JM, Quote Link to comment https://forums.phpfreaks.com/topic/171070-solved-disable-link-if-recordset-0/ Share on other sites More sharing options...
.josh Posted August 20, 2009 Share Posted August 20, 2009 $resultset = 0; // assumed value from db query $img = ($resultset == 0)? "<img src='..' ... />" : "<a href='..'><img src='..' ... /></a>"; Quote Link to comment https://forums.phpfreaks.com/topic/171070-solved-disable-link-if-recordset-0/#findComment-902213 Share on other sites More sharing options...
A JM Posted August 20, 2009 Author Share Posted August 20, 2009 Should this be implemented in HTML like so? <?php $img = ($totalRows_rst == 0)? "<img src='../images/view.png' title='VIEW INVOICE' width='32' height='32' />" : "<a href='qry_open_detail.php?recordID=<?php echo $row_rstcue['inv_num']; ?>'><img src='../images/view.png' title='VIEW INVOICE' width='32' height='32' /></a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/171070-solved-disable-link-if-recordset-0/#findComment-902224 Share on other sites More sharing options...
.josh Posted August 20, 2009 Share Posted August 20, 2009 <?php $img = ($totalRows_rst == 0)? "<img src='../images/view.png' title='VIEW INVOICE' width='32' height='32' />" : "<a href='qry_open_detail.php?recordID={$row_rstcue['inv_num']}'><img src='../images/view.png' title='VIEW INVOICE' width='32' height='32' /></a>";?> Quote Link to comment https://forums.phpfreaks.com/topic/171070-solved-disable-link-if-recordset-0/#findComment-902242 Share on other sites More sharing options...
A JM Posted August 20, 2009 Author Share Posted August 20, 2009 I see that I was adding <?php tags where they weren't needed... no errors on loading the page but no img either? any thoughts? Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/171070-solved-disable-link-if-recordset-0/#findComment-902245 Share on other sites More sharing options...
.josh Posted August 20, 2009 Share Posted August 20, 2009 <?php $img = ($totalRows_rst == 0)? "<img src='../images/view.png' title='VIEW INVOICE' width='32' height='32' />" : "<a href='qry_open_detail.php?recordID={$row_rstcue['inv_num']}'><img src='../images/view.png' title='VIEW INVOICE' width='32' height='32' /></a>"; echo $img; ?> oops. Still needed the echo, just needed to move it. Quote Link to comment https://forums.phpfreaks.com/topic/171070-solved-disable-link-if-recordset-0/#findComment-902265 Share on other sites More sharing options...
A JM Posted August 20, 2009 Author Share Posted August 20, 2009 Sweet! many thanks... A JM, Quote Link to comment https://forums.phpfreaks.com/topic/171070-solved-disable-link-if-recordset-0/#findComment-902436 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.