This topic is locked

How to Deactivate Links

5/10/2007 6:19:50 PM
PHPRunner General questions
W
wengen author

Hello,
Is there a way to de-activate Detail Page links that appear on the Master List page so that if there are no matching detail records, the user is not promted to click on a hyperlink to an empty page? In other words, we want to do this:
Detail Link Column on Master Page:
---------> equals a link to a detail table with matching records
[color=#C0C0C0]Detail ----------->equals a detail table with no matching records (note the faded gray color)
Thanks

J
Jane 5/11/2007

Hi,
you can do the following:

  1. edit SQL query on the Edit SQL query tab. Here is a sample:

    select ForeignKey,

    ForeignKey as DetailLink,

    field_1,

    field_2,

    ...

    field_n

    from MasterTableName


  2. check off DetailLink on the List page only on the Choose fields tab.


  3. set up DetailLink as Custom on the "View as" settings dialog on the Visual Editor tab. Here is a sample code:

    global $conn;

    $str = "select count(*) from DetailTableName where DetailID=".$value;

    $rs = db_query($str,$conn);

    $data = db_fetch_numarray($rs)

    if ($data[0]!=0)

    $value = "<A href=\"DetailTableName_list.php?mastertable=MasterTableName&masterkey1=".$value."\">Details</A>";

    else

    $value = "Details";





where DetailTableName and MasterTableName are your actual table names, DetailID is your actual field name.

W
wengen author 5/11/2007

Jane thanks - that worked great!
Wengen