Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIMITING QUERY RESULTS

Status
Not open for further replies.

kingjjx

Programmer
Joined
Sep 18, 2001
Messages
181
Location
US
Hi, I am trying to set up a query page and I need some help.
HERE'S THE SITUATION:

I have a database that hold different makes and models of cars and each make and model has several testing results .. i.e. test1, test2, test3 where users can input their own test results.

right now, the cfoutput for the query will show #test1#, #test2# .. etc .. and it shows even the balnmk fields. How do i make it just show the test fields that are not empty.

EX. RIGHT NOW ITS SHOWING:
Make : Honda
Model: Accord
Test1: Good
Test2: Bad
Test3:
Test4:

**** see how it still shows test3 and 4 even if its empty, how do i just make it show only the fields that are not empty ??

thank you and i hope i explained what i wanted clearly.
-kingjjx

 
What does your CF Code look like that outputs the page? - tleish
 
can you post the query code please.

cnsisa
 
HEY .. HERE'S WHAT IT LOOKS LIKE .... THANKS


<CFQUERY NAME=&quot;GetResults&quot; DATASOURCE=&quot;DynoRunEx&quot;>
SELECT * FROM RunData WHERE 1 =1
<cfif #form.SearchMake# NEQ &quot;All&quot;>
AND RunData.Make LIKE '%#SearchMake#%'
</cfif>
<cfif #form.SearchModel# NEQ &quot;All&quot;>
AND Rundata.Model LIKE '%#SearchModel#%'
</cfif>

</cfquery>


<TABLE>
<CFOUTPUT query=&quot;GetResults&quot;>
<CFIF (CurrentRow MOD 2) IS 1>
<!--- a row using first color --->
<TR>
<TD bgcolor=&quot;##FFCC99&quot;>MAKE: #Make#</TD>
</TR>
<TR>
<TD bgcolor=&quot;##FFCC99&quot;>MODEL: #Model#</TD>
</TR>
<tr>
<TD bgcolor=&quot;##FFCC99&quot;>RUN1: #Run1Name# </td>
</tr>
<tr>
<TD bgcolor=&quot;##FFCC99&quot;>RUN2: #Run2Name#</td>
</tr>

<CFELSE>
<!--- a row using the second color --->
<TR>
<TD bgcolor=&quot;##EFD6C6&quot;>MAKE: #Make#</TD>
</tr>
<tr>
<TD bgcolor=&quot;##EFD6C6&quot;>MODEL: #Model#</TD>
</TR>
<tr>
<TD bgcolor=&quot;##EFD6C6&quot;>RUN1: #Run1Name#</td>
</tr>

<tr>
<TD bgcolor=&quot;##EFD6C6&quot;>RUN2: #Run2Name#</td>
</tr>

</CFIF>
</CFOUTPUT>
</TABLE>
 
There could be upto 20 Runs for each year and model and it really doesnt look good with the page looking like this :

MAKE: HONDA
MODEL: ACCORD
RUN1: GOOD
RUN2: BAD
RUN3:
RUN4:
RUN5:
RUN6:
RUN7:
RUN20:

Hope you can help ... thank you
 
try this on each row:

<cfif #IsDefined(&quot;Run1Name&quot;)#>
<tr>
<TD bgcolor=&quot;##FFCC99&quot;>RUN1: #Run1Name# </td>
</tr>
</cfif>


hope this helps..
 
HEY !! when i write: (like you wrote above)
<TD bgcolor=&quot;##FFCC99&quot;>RUN1: #Run1Name# </td>

it doesnt work since it still shows the RUN1:

but if i take the RUN1: out .. and just put:
<TD bgcolor=&quot;##FFCC99&quot;> #Run1Name# </td>

it works ... well .. i guess this will be good for now, but if you come up with something .. any help/suggestion will be very much appreciated !!

thank you
-jon
 
Even on empty records, it will still pass that there is &quot;something&quot; there, so check to see if the value is null or blank -- the IsDefined just checks to see if the record value exists, which it will, even if blank.

try this:
<cfif Run1Name is NOT &quot;&quot;>
<tr>
<TD bgcolor=&quot;##FFCC99&quot;>RUN1: #Run1Name# </td>
</tr>
</cfif>


Tim P.
 
Usually empty fields will still be defined, just left empty, so try:

<cfif #Run1Name# NEQ &quot;&quot;>
<tr>
<TD bgcolor=&quot;##FFCC99&quot;>RUN1: #Run1Name# </td>
</tr>
</cfif>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top