This topic is locked

V6.2 Hide Button

2/8/2013 9:03:07 AM
PHPRunner General questions
J
jacques author

Hi,
Can anyone help me out (with a suggestion or example) how to hide the add-button on a list page depending the number of rows in a table.
I thought I knew how to do this but I forgot it. Shame on me.
Thanks,
Jacques

C
copper21 2/8/2013

Jacques,
You can try this; I think it might work:
List Page: After record processed
global $conn;

$strSQLSelect = "SELECT COUNT(some_filed) AS Table_Count FROM YOUR_TABLE ";

$rsSelect = db_query($strSQLSelect,$conn);

$data1=db_fetch_array($rsSelect);
if($data1["Table_Count"] >= 'some_number')

{

$record["add_link"] = false;

}

else

{

$record["add_link"] = true;

}
You can use $data["field_name"] on this page as well in your $strSQLSelect query if you need to narrow your results down further than just getting a total count for the whole table.
global $conn;

$strSQLSelect = "SELECT COUNT(some_filed) AS Table_Count FROM YOUR_TABLE WHERE some_field = '".$data[some_field_on_list_page"]."'";

$rsSelect = db_query($strSQLSelect,$conn);

$data1=db_fetch_array($rsSelect);