HREF link vith PHP...

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Cr00zng
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Jun 29, 2019 12:04 pm

Sat Jun 29, 2019 12:21 pm

I am trying to replace the actual URL with some word, like Website in this code:

Code: Select all

a href="'<?php $cap->web; ?>'" target="_blank"><?php echo $cap->web; ?></a>
Replacing with this code:

Code: Select all

<a href="'<?php $cap->web; ?>'" target="_blank">Website</a>
The word "Website" is displayed; however, the link for this word shows up as dev.claims.org/" and results in a 404 error as it should. The link is the actual development website, so go easy.

I've been trying to see what I did wrong, but running in circles. Could anyone point out what I am doing wrong?

TIA...

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 839
Joined: Mon Feb 22, 2016 5:52 pm

Sat Jun 29, 2019 1:10 pm

Without seeing the code in your 'web' method, we can't help you, even then we may need more.

I will however point out that using "_blank" is considered bad practice in anchors unless you have indicated that the link will open in a new window, most of the time you don't need to do this as users can decide for themselves and know how to do it.

Cr00zng
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Jun 29, 2019 12:04 pm

Sun Jun 30, 2019 1:16 pm

Thanks...

About the "_blank"... Yes, I understand, but this has been the preference of the organization. I might just add a warning just above the members list...

I am not certain how much of a code you'd need, but some background. The members' information is stored in a database from where, PHP pulls the data and generates the members' list and the page. All information defined as:

Code: Select all

				$caps[] = (object) [
					'id' => $id,
					'company' => $cname,
					'address' => $add2,
					'contact' => $contact,
					'phone' => $phone,
					'email' => $email,
					'web' => $webpage,
					'image' => $imagetoshow,
					'pdf' => $profilepdf,
				];
This works well, with the only exception that stated in the initial posting. I've tried a number of variation, but had not been able to get the right syntax. The reason for replacing the actual links is that some of them too long and wraps around 2-3 lines.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 839
Joined: Mon Feb 22, 2016 5:52 pm

Sun Jun 30, 2019 2:13 pm

ok, where is $webpage defined?

Did your first code sample work?

Post Reply