This topic is locked

Combining 2 fields in 1 hyperlink

3/28/2008 1:59:04 PM
PHPRunner General questions
N
nadimo author

Hello,

I really would appreciate some help with PHPRunner.
I have a field that contains ISBN numbers of books say number: 0789736659 , I have another field that contains a static

text such as : http://www.amazon.com/exec/obidos/tg/detail/-/
What should I do in the list view to enable the user to click on the static

field so it will show a hyperlink that combines the static field and ISBN number to display the result : http://www.amazon.com/exec/obidos/tg/detail/-/0789736659/
That is combine 2 fields to display 1 resulting hyperlink .
Hope someone can help .
Thanks .
Nadimo.

A
alang 3/28/2008

Use "View as" Custom field in the visual editor. Assuming you have fields called "ISBN" and "WebLink", set up the WebLink field as the custom field on your list page. In the text box for view as settings:
$value = "<a href=".$data["WebLink"].$data["ISBN"].">".$data["WebLink"];
Alternatively you could turn the ISBN field into a hyperlink with the WebLink part specified as URL Prefix - again on visual editor, selecting Hyperlink as the "View as" setting.

N
nadimo author 3/29/2008

Thanks for the help . greatly appreciated.

nadimo
P.S. Are you good at PHP programming ?

A
alang 3/31/2008

Thanks - I have done a bit of PHP but it is not really my main line of work.

N
nadimo author 4/1/2008

Thanks - I have done a bit of PHP but it is not really my main line of work.


Hello again,
Can you help one more time please :
Here is a tough one :
The 2 links below are static , exactly the same , except inside each link there are 2 identical ISBN numbers : 1590598989 and 0321509366
http://www.amazon.com/gp/product/159059898...ASIN=1590598989
http://www.amazon.com/gp/product/032150936...ASIN=0321509366
The database has the ISBN field . So how do you write a custom code to grab the ISBN number from the database and combine it with the static portion of the link ??
Any ideas ?. Any help is greatly appreciated .
Thanks in advance.
nadimo.

N
nadimo author 4/1/2008
A
alang 4/1/2008

You do need to use the custom field option for this. It depends where you want to store the middle part of the URL - in another database field or hardcoded - it depends whether the values need to be easily changed or not. For example if hardcoding was OK you could do:
$urlparms="/002-9602736-5755241?ie=UTF8&tag=danouma-20&linkCode=xm2&camp=1789&creativeASIN="

$value = "<a href=".$data["WebLink"].$data["ISBN"].$urlparms.$data["ISBN"].">".$data["WebLink"]."</a>";
(Sorry - I left off the closing </a> tag in my first post)
or depending on what you want to display for the link (this would be my preference as the view is less cluttered):
$value = "<a href=".$data["WebLink"].$data["ISBN"].$urlparms.$data["ISBN"].">".$data["ISBN"]."</a>";
Alternatively if you stored the text in another database field (where you could edit it if necessary) in the same table called "urlparms" then it would be:
$value = "<a href=".$data["WebLink"].$data["ISBN"].$data["urlparms"].$data["ISBN"].">".$data["ISBN"]."</a>";

N
nadimo author 4/1/2008

WOW !!!,

Thanks a million, I will work on it .

Meanwhile , I need to ask you : if I create another table in the same database

that contains the books ISBN etc..info . Let us assume that the new table is called "amazonparam" and it has 2 fields for the 2 portions of the url that are static , we call them "param1" and "param2" .

On the side line, I guess I have to create a new field in the books table that can be a text field with a static data like "buy from" or "go to Amazon" that will hold all this info i.e. param1 and param2 and the ISBN numbers ..right ?, because I want the ISBN number to appear in the view page , and I do not believe that hovering over a hyperlinked ISBN number will show the entire url we are trying to achieve , right ?

So, could you please show me the code that will encompass , param1 and param2 from "amazonparam" table and ISBN numbers from the books table ? and this custom coding where would it go ?

. In the custom field of the ISBN number ?

. Or in a field from another table which I guess is more complicated .

Sorry for all this mess .

Thanks in advance for all the effort and help.

nadimo.

N
nadimo author 4/2/2008

Ok,

it worked with this code.
$urlparms1="http://www.amazon.com/gp/product/";;
$urlparms2="/002-9602736-5755241?ie=UTF8&tag=danouma-20&linkCode=xm2&camp=1789&creativeASIN=";
$value="<a href=".$urlparms1.$data["ISBN"].$urlparms2.$data["ISBN"].">".$data["ISBN"]."</a>";
thanks a lot
nadimo.