1 Replies - 3317 Views - Last Post: 05 June 2006 - 12:59 PM Rate Topic: -----

#1 EuniQ  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 16-May 06

cfQuery to display all results

Posted 03 June 2006 - 11:56 PM

I have been working on a Coldfusion form with a SQL databse and wish to add to the list menu a selection that returns all the records in the database. Can anyone help me to do this? I am not familiar with the SQL language should this be in the SQL forum section. I hope I posted it in the proper place.

The code below is the form page and results page.

Form Page:
<form action="getRecord.cfm" method="get" name="RecordForm">
  <select name="productType" size="1" id="productType">
	<option value="HW">Hardware</option>
	<option value="AN">Audit Number</option>
	<option value="SW">Software</option> 
  </select>
   
 <input name="Search" type="submit" id="Search" value="Search">
</form>



Results Page:
<cfquery name="GetRecord" datasource="***" dbtype="query" username="***" password="*****">
	select * from rr.record where ITEM_CLASS = 'HW' order by UNIT_PRICE
</cfquery>



This post has been edited by EuniQ: 04 June 2006 - 04:51 AM


Is This A Good Question/Topic? 0
  • +

Replies To: cfQuery to display all results

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1875
  • View blog
  • Posts: 20,283
  • Joined: 17-March 01

Re: cfQuery to display all results

Posted 05 June 2006 - 12:59 PM

I may not be 100% clear on what you're trying to do, but I'll give it a shot.

You've got a drop down menu with these options:
	
<option value="HW">Hardware</option>
<option value="AN">Audit Number</option>
<option value="SW">Software</option> 



You want an option to display All records instead of just HW, or AN... So you would have this:

<option value="View All">View All</option>
<option value="HW">Hardware</option>
<option value="AN">Audit Number</option>
<option value="SW">Software</option> 



Then on your result page your query should look something like this:
<cfquery name="GetRecord" datasource="***" dbtype="query" username="***" password="*****">
SELECT * from rr.record 
<cfif form.productType NEQ "View All">
WHERE ITEM_CLASS = '#form.productType#'
</cfif>
ORDER BY UNIT_PRICE
</cfquery>



This way the query will only filter by item_class if the option selected wasn't "View All". Hope that helps!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1