This topic is locked

List Page

5/16/2007 5:00:37 PM
PHPRunner General questions
W
wengen author

Hello:
Is there an easy way to create an Export function on the Master List page that will export all Detail table matching records where the foreign keys match? For Example:
Master table contains company names with key (ID):
Master Table:
ID | Company | Address

1 | BMW AG | 123 some road

2 | Saab AB | 345 any road
Detail table contains all people who work for the companies with the same key (ID)
Detail Table:
ID | Name | Title

1 | Jon Schmidt | CEO

1 | Pam Wu | President

2 | Mike Hoffman | President
So if I do a Master Table Advanced Search "ID 1", the list page will return:
1 BMW AG 123 some road
I want there to be an export function on the Master List page to export:
1 Jon Schmidt CEO

1 Pam Wu President
I tried a joining the Master & detail table where master.id = detail.id, but when I do a Search for "Company_ID 1", I get dupe rows like this:
1 BMW AG 123 some road

1 BMW AG 123 some road
Thanks!

J
Jane 5/17/2007

Hi,
you can do the following:

  1. create View of the detail table on the Datasource tables tab (DetailTableView for example), set up this view as detail table for the MasterTable.
  2. proceed to the Visual Editor tab, turn on HTML mode find and edit link to this view on the MasterTable list. See my changes in Bold:
    <A href="DetailTableView_list.php?{$row.1DetailTableView_masterkeys}"

    {if $useAJAX} onmouseover="showDetailsPreview(this,'DetailTableView_detailspreview.php?{$row.1DetailTableView_masterkeys}');" onmouseout="hideDetailsPreview(this);" {/if} target=_blank>export detail records</A>


3. add ListOnLoad event on the Events tab for the DetailTableView table:

function ListOnLoad()

{

?><script>

window.location='./DetailTableView_export.php';

</script><?php

}


DetailTableView and MasterTable are your actual table names.

W
wengen author 5/17/2007

Jane I am sorry I was not clear.
We want to export all Detail table matches for a given Master Table Advanced search.
So if you assume the Master table is:
ID | Company | Address |Country

1 | BMW AG | 123 some road | Germany

2 | Saab AB | 345 any road |Sweden

3 | Porsche AG | 567 Road A |Germany
...and the Detail table is:
ID | Name | Title

1 | Jon Schmidt | CEO

1 | Pam Wu | President

2 | Mike Hoffman | President

3 | Dr. Porsche | Chairman
If I do an advanced search (Master Table) for all companies in Germany, the Master Table Advanced Search list results would be:
1 | BMW AG | 123 some road | Germany

3 | Porsche AG | 567 Road A |Germany
...and the "Export all DetailTable matches" results would be:
1 | Jon Schmidt | CEO

1 | Pam Wu | President

3 | Dr. Porsche | Chairman
....because these people work for companies in Germany (Master Table Advanced Search was for all companies in Germany)
So we want the "Export all DetailTable Matches" link to be just one link at the top of the Master Table List search results.
Is this possible?
Thanks again!

J
Jane 5/17/2007

Try to use following solution:

  1. add following link on the List page of the MasterTable on the Visual Editor tab:

    <a href="DetailTable_export.php?contacts=1">Export all DetailTable Matches</A>


  2. add ExportOnLoad event for the detail table. Here is a sample code:

    function ExportOnLoad()

    {

    global $conn,$gstrSQL,$strTableName;

    if(@$_REQUEST["contacts"])

    {

    $conn=db_connect();

    $rs=db_query($_SESSION["MasterTable_sql"],$conn);

    $sql = $gstrSQL;

    $list="";

    while($data=db_fetch_array($rs))

    {

    if($list)

    $list.=",";

    $list.=$data["ID"];

    }

    $_SESSION[$strTableName."_sql"]=AddWhere($gstrSQL,"ID in (".$list.")");

    }

    }



W
wengen author 5/17/2007

Jane Thanks - that works great!

W
wengen author 4/7/2008

Jane Thanks - that works great!


Jane,
We just upgraded to 4.2 & the export function is now not working correctly. It is now exporting all records in the detail table instead of only those where "ID" = "ID"
Any suggestions?
Thanks
Wengen

J
Jane 4/8/2008

Hi,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

W
wengen author 4/8/2008

Hi,

it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.


ok thanks
wengen