 | |  |
 |

gethudson
Novice
May 11, 2008, 7:15 AM
Post #1 of 4
(1340 views)
Shortcut
|
|
Hyperlinking to other table data
|
Can't Post
|
|
Hello there. I have looked to an answer for the following and I cannot find it in the knowledgebase. I suspect that this is probably because I am new to PHP, so please bear with me. I hope you can help. I have two sections/tables. The first is called ‘issue’ and has one text field called ‘issuemonth’ into which a year and month are typed in the format ‘yyyymm’. This list viewer appears as I want it: Issue - List Page Viewer Issue for: 200806 Issue for: 200805 The second section/table is called ‘page’ and has two fields: a text field called ‘page_number’ into which a page number (001, 002, …) is typed, and ‘assign_issue’ which uses a picklist generated from the ‘issuemonth’ field in the ‘issue’ table. The list viewer page appears like this: Page - List Page Viewer Issue: 200806 - Page Number: 001 - Link: pageDetail.php?8 Issue: 200806 - Page Number: 002 - Link: pageDetail.php?6 Issue: 200805 - Page Number: 001 - Link: pageDetail.php?1 Issue: 200805 - Page Number: 002 - Link: pageDetail.php?2 What I am struggling to achieve is that I want to be able to click on a link in the Issue - List Page Viewer page and be sent to something that looked like the Page - List Page Viewer page, but only showing records that related to the ‘issuemonth’ that had been clicked. Code – top of Issue - List Page Viewer: list($issueRecords, $issueDetails) = getRecords(array( 'tableName' => 'issue', )); Code – body of Issue - List Page Viewer: <?php foreach ($issueRecords as $issueRecord): ?> Issue for: <a href="<?php echo $issueRecord['_link'] ?>"><?php echo $issueRecord['issuemonth'] ?></a> <hr/> <?php endforeach; ?> Code – top of Page - List Page Viewer: list($pageRecords, $pageDetails) = getRecords(array( 'tableName' => 'page', )); Code – body of Page - List Page Viewer: <?php foreach ($pageRecords as $pageRecord): ?> Issue: <?php echo $pageRecord['assign_issue'] ?> - Page Number: <?php echo $pageRecord['page_number'] ?> - Link: <a href="<?php echo $pageRecord['_link'] ?>"><?php echo $pageRecord['_link'] ?></a> Thanks for any assistance in advance, George
|
|
|  |
 |

Dave
Staff
/ Moderator

May 11, 2008, 9:26 AM
Post #2 of 4
(1335 views)
Shortcut
|
|
Re: [gethudson] Hyperlinking to other table data
[In reply to]
|
Can't Post
|
|
Hi George, welcome to the CMS Builder forum! The first step is figuring out how to get your "Page List" only showing records that are in a specific issue. All the viewers have search capabilities enabled by default (unless you turn it off). Try this: yourPageListViewer.php?issuemonth=200806 And have a look at the search docs here: http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html If that works you just need to add that to the links in the issue list viewer, like this: <a href="<?php echo $issueRecord['_link'] ?>?issuemonth=<?php echo $issueRecord['issuemonth'] ?>"><?php echo $issueRecord['issuemonth'] ?></a> Hope that helps! Let me know if that works for you. :) Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

gethudson
Novice
May 12, 2008, 2:26 AM
Post #3 of 4
(1270 views)
Shortcut
|
|
Re: [Dave] Hyperlinking to other table data
[In reply to]
|
Can't Post
|
|
Thank you Dave. It's easy when you nkow how! Yes, I get it. All pages are searchable, therefore you just append the correct parameter then copy & paste that into your code and add on the PHP bit that adds on that parameter. It can't all be that easy though, I'm sure. Just for the record in case it helps any other newbie, then here is my final code: <?php foreach ($issueRecords as $issueRecord): ?> Issue for: <a href="pageList.php?assign_issue=<?php echo $issueRecord['issuemonth'] ?>"> <?php echo $issueRecord['issuemonth'] ?></a> <hr/> <?php endforeach; ?>
(This post was edited by gethudson on May 12, 2008, 2:28 AM)
|
|
|  |
 |

Dave
Staff
/ Moderator

May 12, 2008, 1:20 PM
Post #4 of 4
(1195 views)
Shortcut
|
|
Re: [gethudson] Hyperlinking to other table data
[In reply to]
|
Can't Post
|
|
Glad to hear it's working, and thanks for posting your code! :) Dave Edis - Senior Developer interactivetools.com
|
|
|  |
|