2 Replies - 1733 Views - Last Post: 16 May 2011 - 06:16 PM Rate Topic: -----

#1 roshan737  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-May 11

cold fusion code - search partial product name

Posted 14 May 2011 - 08:28 PM

This is my cold fusion code to search product from a database.

How can i Allow the user to search for products by entering a partial product name?

<h1>Results</h1>

<form action="" method="" name="resultForm" accept-charset="utf-8">
	<p>
	<cfquery name="GetParts" datasource="" username="" password="">
				Select * From PP_Parts where 1=1
				<cfif '#ProductName#' Is Not "">
					and PP_Parts.PART_DESCRIPTION Like <cfqueryparam value = '%#ProductName#%' cfsqltype = "cf_sql_char" > 
 				</cfif>
				<cfif '#min#' Is Not "">
					and PP_Parts.UNIT_PRICE >= <cfqueryparam value = '#min#' cfsqltype = "cf_sql_float" > 
 				</cfif>
				<cfif '#max#' Is Not "">
					and PP_Parts.UNIT_PRICE <= <cfqueryparam value = '#max#' cfsqltype = "cf_sql_float" > 
 				</cfif>
				order by UNIT_PRICE				
		</cfquery>


This post has been edited by Craig328: 15 May 2011 - 10:04 AM
Reason for edit:: Please enclose code in code tags


Is This A Good Question/Topic? 0
  • +

Replies To: cold fusion code - search partial product name

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: cold fusion code - search partial product name

Posted 15 May 2011 - 10:06 AM

Welcome to D.I.C., Roshan.

If you look at lines 7 & 8 you'll see that while you're passing in ProductName as the search criteria, you're searching against PART_DESCRIPTION in your PP_Parts table. If that table has a product name field, changing from PART_DESCRIPTION to that product name field should get you where you want to be.

Good luck!

This post has been edited by Craig328: 15 May 2011 - 10:09 AM

Was This Post Helpful? 0
  • +
  • -

#3 roshan737  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-May 11

Re: cold fusion code - search partial product name

Posted 16 May 2011 - 06:16 PM

hi ,

Thannks for reply

Actually,.PART_DESCRIPTION: the name of the product
.UNIT_PRICE: sale price of each item
database structure of the products table PP_PARTS.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1