Link to home
Start Free TrialLog in
Avatar of zakirdavis
zakirdavis

asked on

If Row has a value, then display URL

I want to do this.

Show rows from my table dynamically. I know how to do this.

If the current record being shown does not have an empty value in the Description column, then show the words DESC.

DESC will be a link that opens a new window showing only that particular records Description field.

<TABLE WIDTH="99%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
  <TR>
    <TD>ID</TD>
    <TD>Type</TD>
    <TD>Description</TD>
  </TR>
  <cfoutput QUERY="cars">
  <TR>
 
    <TD>#ID#</TD>
    <TD>#VehicleType#</TD>
    <TD>#Description#</TD>
  </TR></cfoutput>
</TABLE>
Avatar of jyokum
jyokum
Flag of United States of America image

<cfoutput QUERY="cars">
  <TR>
    <TD>#ID#</TD>
    <TD>#VehicleType#</TD>
    <TD>
    <cfif len(cars.description)>
      <a href="whatever.cfm?ID=#cars.ID#">DESC</a>
    </cfif>
    </TD>
  </TR>
</cfoutput>
Avatar of zakirdavis
zakirdavis

ASKER

For the page whatever.cfm,

In order to be able to reuse this page for my other tables, i think i will want to pass what table it is coming from. I have a hidden input field for this traveling from the original page that states what table it is coming from.

ex. on my cars.cfm page, i created a hidden field (TYPEFLAG) with value=cars.
on trucks.cfm page, i created a hidden field (TYPEFLAG) with  value=trucks

I know i will have to have a CFQUERY to talk to the DB (on the whatever.cfm page), but how will i take the value from the URL and use it in my CFQUERY?

??
<CFQUERY name="allVehicles" datasource="Vehicles">
SELECT Desc FROM #TYPEFLAG# Where ID IS url.whatever
</CFQUERY>
??

Also, how would i append more than one value to the url?

??
<a href="whatever.cfm?ID=#cars.ID#"&Table=#TYPEFLAG#>DESC</a>
??
ASKER CERTIFIED SOLUTION
Avatar of jyokum
jyokum
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so very much. You are a big help!