Link in MySQL:
https://wahlburgers.com/dorchester

Variable loaded:
$website = $row["website"];

How can I echo the word "Website" as a hot link to $website ( https://wahlburgers.com/dorchester ) inside an HTML form?

This is what I've tried:
<input type="text" id="website" name="website" value="<?php echo "<a href= '" . $website . "'>" . "Website" . "</a>"; ?> ">

Thanks . . .

rproffitt commented: Great. Now I want a burger. +15

Recommended Answers

Are your using native PHP or a PHP framework such as Laravel, Codeigniter, etc? Are you using a PHP templating system? (If not, you should be!)

Please show your full code on the page. Are you sure $row contains the MySQL query row data you are looking for as an …

Jump to Post

All 3 Replies

Are your using native PHP or a PHP framework such as Laravel, Codeigniter, etc? Are you using a PHP templating system? (If not, you should be!)

Please show your full code on the page. Are you sure $row contains the MySQL query row data you are looking for as an associative array?

commented: Igniter. Light up the grill. +0
commented: and don't tell me what I should do -- although I am wide open to suggestions. +0

and don't tell me what I should do -- although I am wide open to suggestions.

Sorry if it came across as insulting. I simply mean that, if you're first learning PHP or taking an introductory class in school, you might not be using a PHP templating system. However, for any actual web apps that you wish to build with PHP, you're pretty much always going to be using a PHP templating system. I've been doing PHP for 20+ years, and have not ever come across any PHP-based projects that don't use PHP templates. It simply means separating the HTML code from the PHP logic.

My reason for asking the question is you're saying you have $website = $row["website"];, but where, exactly, is that code? What do you mean by "variable loaded"? I've heard of loading a variable into a templating system, for use by your templates, if that's what you mean?

Typically you will have a PHP file that looks something like:

// ... Logic to fetch $row from the database
// blah blah blah

// Load variable into the template
load_variable('website', $row['website']);

And then you'll have your template file that looks something like:

<a href="<?= $website ?>">Click Here</a>

I'm still confused what you mean by variable loaded and where it is in relation to your HTML within the PH file. That's why I asked if you could please show your full PHP code.

Secondly, i'm not sure I understand what you mean by making a hot link inside an HTML form. A hyperlink cannot exist within an HTML input form. You can use some fancy javascript so that if you click on the input form, it launches a page, but it can't be built as HTML on its own.

commented: "And don't call me Shirley." - Airplane. Going to have to spin up the DVD but first "Die Hard" for XMAS! +15

All hot link text is color red. Highlight the url and change the font color to red by compose method. Html editor method toggle tools go to inspector pick an element from the page which is the url inspect from filter style and change the attribute of the element. From blue color to red

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.