• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

display active link.

New Here ,
Apr 01, 2016 Apr 01, 2016

Copy link to clipboard

Copied

if someone types a url into a form field and it goes into a mysql database. how do i get it to display as an active link on the display page.

Views

511

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 03, 2016 Apr 03, 2016

aetb846k wrote:

Thanks i changed all those settings without a problem...So basically i want to take a url (e.g. http://www.google.com)  thats stored in my data base and display as an active link to the url http://www.google.com

I answered that earlier:

<td><a href="#Recordset1.name#" title="Google homepage">Google</a></td>

This assumes that the value of Recordset1.name is  http://www.google.com

Votes

Translate

Translate
Community Expert ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

<!--- Do select query to retrieve URL from database --->

<cfquery name="orgDetails" datasource="myDSN">

select orgID, webURL

from someTBL

where orgID=1234

</cfquery>

<!--- Display link on page --->

<a href="#orgDetails.webURL#" title="Organisation X homepage">Organisation X</a>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

<p>thanks for your time!  I tried to manipulate that code into what i have and it's throwing internal server error.  I'd like the name field to be the active link from the url they type in.    heres what i have for my output code.

<cfoutput query="Recordset1">

    <tr>

      <td>#Recordset1.breed# </td>

      <td>#Recordset1.name#</td>

      <td>#Recordset1.bred# </td>

     <td>#Recordset1.due# </td>

    </tr></p>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

Since you want a link, I expected something like

<td><a href="#Recordset1.name#" title="Some title">Some name</a></td>

In any case, the internal server error suggests something else is playing up. Could you show us your query.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

Thanks for the quick reply!

INSERT INTO litters (breed, name, bred, due)

VALUES (<cfif IsDefined("FORM.breed") AND #FORM.breed# NEQ "">

<cfqueryparam value="#FORM.breed#" cfsqltype="cf_sql_clob" maxlength="50">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.name") AND #FORM.name# NEQ "">

<cfqueryparam value="#FORM.name#" cfsqltype="cf_sql_clob" maxlength="50">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.bred") AND #FORM.bred# NEQ "">

<cfqueryparam value="#FORM.bred#" cfsqltype="cf_sql_clob" maxlength="50">

<cfelse>

''

</cfif>

, <cfif IsDefined("FORM.due") AND #FORM.due# NEQ "">

<cfqueryparam value="#FORM.due#" cfsqltype="cf_sql_clob" maxlength="50">

<cfelse>

''

</cfif>

)

  </cfquery>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

One immediate remark: a CLOB with a maxLength of 50? I would use cf_sql_varchar in place of cf_sql_clob. Unless of course you have a good reason to use CLOB type. For example, are the columns of the table litters of type CLOB?

Also, use the null attribute of the cfqueryparam tag. It is False by default. However, if you set it to True, the query will ignore the value attribute and insert Null into the database table. Something like this

<cfset isBreedNull = true>

<cfset isNameNull = true>

<cfset isBredNull = true>

<cfset isDueNull = true>

<cfif IsDefined("FORM.breed") AND FORM.breed NEQ "">

    <cfset isBreedNull = false>

</cfif>

<cfif IsDefined("FORM.name") AND FORM.name NEQ "">

    <cfset isNameNull = false>

</cfif>

<cfif IsDefined("FORM.bred") AND FORM.bred NEQ "">

    <cfset isBredNull = false>

</cfif>

<cfif IsDefined("FORM.due") AND FORM.due NEQ "">

    <cfset isDueNull = false>

</cfif>

INSERT INTO litters (breed, name, bred, due)

VALUES (

        <cfqueryparam value="#FORM.breed#" cfsqltype="cf_sql_varchar" maxlength="50" null="#isBreedNull#">

        ,<cfqueryparam value="#FORM.name#" cfsqltype="cf_sql_varchar" maxlength="50" null="#isNameNull#">

        ,<cfqueryparam value="#FORM.bred#" cfsqltype="cf_sql_varchar" maxlength="50" null="#isBredNull#">

        ,<cfqueryparam value="#FORM.due#" cfsqltype="cf_sql_varchar" maxlength="50" null="#isDueNull#">

)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

Thanks i changed all those settings without a problem...So basically i want to take a url (e.g. http://www.google.com)  thats stored in my data base and display as an active link to the url http://www.google.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 03, 2016 Apr 03, 2016

Copy link to clipboard

Copied

aetb846k wrote:

Thanks i changed all those settings without a problem...So basically i want to take a url (e.g. http://www.google.com)  thats stored in my data base and display as an active link to the url http://www.google.com

I answered that earlier:

<td><a href="#Recordset1.name#" title="Google homepage">Google</a></td>

This assumes that the value of Recordset1.name is  http://www.google.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2016 Apr 03, 2016

Copy link to clipboard

Copied

LATEST

Thanks BK!  I got it!  Yeah!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation