Linked records ?

17 posts by 4 authors in: Forums > CMS Builder
Last Post: November 21, 2013   (RSS)

By Rewmer - October 8, 2013

Just mulling over a few ideas for the site I work on. Its for a snake breeder and I have set up records for when they breed, eggs layed,off spring etc on one section editor

and then I have set up another for snakes that ultimatly come up for sale. I wonder can I somehow get my list page on the breeding to throw up

a link to the "Available" ?

Just thinking aloud I guess I would need to have some form of common data between each recordset ie a ref code or similar.

Would I have to load both recordsets on my page ?

ANy thoughts most welcome

Andy

By Rewmer - October 9, 2013

In a moment of clarity brought on by the sedative from my tooth extraction today, I guess I only need to create a link on the breeding page to the relevant availabe records.  Any ideas how I would achieve this ?

By Chris - October 9, 2013

Hi Rewmer,

I'm not sure exactly how your sections work (can you list the fields in each here?), but creating a link between two sections typically starts with creating a List Field with List Options = "Get options from database (advanced)", then you select the other table and the fields to use. It's almost always a good idea to use "num" as the value field. It's also much simpler to use the Display As "pulldown" or "radio buttons" option (not the "pulldown (multi value)" or "checkboxes (multi value)" options)

Which table you create the List Field in depends on whether single records in table A are to be associated with multiple records in table B, or if single records in table B are to be associated with multiple records in table A. If I understand your explanation above, a snake breeder would own multiple snakes-for-sale, therefore you would want to create the List Field on the snakes-for-sale table (you can call the List Field "Snake Breeder"). Then, when adding a snake-for-sale, you would select the breeder who's selling it from the pulldown.

Please let me know if this helps or if you have any questions!

All the best,
Chris

By Rewmer - October 10, 2013

Hi Chris, thanks for the ideas. One of the downfalls of only playing with this site perhaps once a year, is I forget what Ive done and to a good part - how it works ! after a bit of refreshing I have realized that

each clutch of snakes when born are given a unique identifier which is noted in the Clutch No. record in the the breeding / incubator record set. Also any of these snakes that are put into the available animals recordset are also identified by that same clutch No.

Just to make sure I`m not confusing things  - there is a section editor for "Breedings / incubator" and a separate one for "Available" 

Here is the page for the record of the hatchings - http://www.genetic-gems.com/pages/royalincubator2013.php

and this is the page for the available animals - http://www.genetic-gems.com/pages/royalavailable2.php - (note data is out of date on this page.)

All I really need to do is have a link on each "incubator" result that links through to a separate page that shows just the one record that is called from the incubator page - perhaps a search results page with the key word

being an exact match to the clutch No. ??

Hope this makes sense, Im sure its going to be real simple..

Thanks again for your help

Andy

By Rewmer - October 17, 2013

Anyone have any thoughts on this ????

By Chris - October 17, 2013

Hi Rewmer,

I think I understand. You want to add a link to each "incubator" section record listed on http://www.genetic-gems.com/pages/royalincubator2013.php to a page that shows the "available" section record with the same Clutch No..

Check this out: http://www.genetic-gems.com/pages/royalavailable2.php?clutch_no=9

CMS Builder automatically (by default) allows list pages to search on any fields; therefore, adding a link inside your foreach in royalincubator2013.php like this should work:

<a href="royalavailable2.php?clutch_no=<?php echo $record['clutch_no'] ?>">See available animals</a>

Note that you will need to change the $record variable name to the same variable name as in your foreach loop. It's probably something like $breedings_incubatorRecord.

If you run into any trouble or I misunderstood your requirement. Please attach the source code of your pages so we can see what your section names, field names, and variable names are.

Hope this helps!

All the best,
Chris

By Rewmer - October 18, 2013

Beautiful !

Works a treat, just what I was after Thanks very much Chris.

Thinking along the same lines, I tried to get it to link direct to the details page by

By doing this <a href="royalavailabledetail.php?clutch_no=<?php echo $record['cluth_no'] ?>">See available animals</a>

 but to no avail. Is this possible ? (oh and the variable "cluth_no" is spelled correctly - typo when I set up the DB)

Andy

By Rewmer - October 20, 2013

Been playing with this all weekend and still can't get it. Any suggestions to get the link through to the details page ?

Andy

By ross - October 22, 2013

Hi Andy

Could you post a copy of your detail page for me to review? Or at least paste in a copy of all the PHP code at the top of the page. 

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/