This topic is locked

Linking field

12/10/2008 7:21:56 PM
PHPRunner General questions
unitedintruth author

I am creating a script for canine pedigrees. I have fields for dogs mother and dogs father. I need, when clicking on view a pedigree, the mother and fathers name fields to be a link to their pedigrees.
Can anybody give me a hint how I could make this work with phprunner 5.0?
Thanks,

Donnie

T
thesofa 12/11/2008

Just a few thoughts about database design that might help

hold each dog's details of make, breed, date of birth, owner etc in a tablecalled Dog and give each dog a Unique identifier using auto increment.

have another table of Parentage, 3 field of dog, mum, dad

and just use the ID numbers of the dogs in this table. Set your main table as the parentage table, create 2 custom views where you link the parentage table to the dog table, one called Mummy linking on the Mum field to the dog table and one called Daddy linking on the dad field.

Make a third View called Doggy, now set doggy as the master table to the Mummy and Daddy views
The custom views should each link the Parentage table to the Dog table and use the dog details as the display fields.

This will give you links on the list page for the dogs as Mummy and Daddy.
HTH

T
thesofa 12/11/2008

tried it and made it simpler, just have one table and 2 custom views, I have put the files on my web page for you to try

just click here

HTH

unitedintruth author 12/11/2008

I made a PDF of my add pedigree page, and my view pedigree page. If you look at them I need the sire and dam to link to the sire and dams pedigree.
http://americanmi-kiregistryassociation.com/Pedigrees.pdf

http://americanmi-kiregistryassociation.co...igrees_view.pdf
I do have an auto increment field in the database called "id" that can be used but I am completely lost how to use it.
Thanks again,

Donnie

J
Jane 12/12/2008

Hi,
use custom format on the "View as" settings dialog on the Visual Editor tab for Sire and Dam fields.

Here is a sample:

global $conn;

if (@$_REQUEST["editid1"])

{

$str = "select Id from Pedigrees where Sire='".$value."'";

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

$data = db_fetch_array($rs);

$value = "<a href=\"Pedigrees_view.php?editid1=".$data["Id"]."\">".$value."</a>";

}

unitedintruth author 12/12/2008

Thank you Jane,
I did as you suggested,

global $conn;

if (@$_REQUEST["editid1"])

{

$str = "select Id from Pedigrees where Sire='".$value."'";

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

$data = db_fetch_array($rs);

$value = "<a href=\"Pedigrees_view.php?editid1=".$data["Id"]."\">".$value."</a>";

}


now they are linking, but they are all linking to the current page, for instance if I am viewing editid1=40 the sire and dam field also link to 40 rather than their own id.
Please help me, I am at my wits end.
Thank you,

Donnie

J
Jane 12/15/2008

Donnie,
It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

unitedintruth author 12/15/2008

Donnie,

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.


I am on dial-up and it takes forever to upload it again, could I just PM you the login to go check it out on my server?
Thanks,

Donnie

J
Jane 12/16/2008

Hi,
to debug your code print all queries and variables on the page using echo statement:

echo $str;


Also you can open a ticket at http://support.xlinesoft.com sending a detailed description of what you're doing.

unitedintruth author 12/16/2008

I added that to the statement on the sire field. When I place that echo at the end of the statement I get.

select id from _pedigrees where Sire='Tiny Tots Cute As A Button of Shekinah'


Tiny Tots Cute As A Button of Shekinah is the name of the sire.
Thanks,

Donnie

J
Jane 12/17/2008

I suppose you need to select record where Name is Tiny Tots Cute As A Button of Shekinah, not Sire.

$str = "select Id from Pedigrees where Name='".$value."'";

unitedintruth author 12/19/2008

Jane, you are the most awesome one in the world.
They work now, thank you so much, I owe you the world.
Thanks,

Donnie