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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping in ColdFusion 1

Status
Not open for further replies.

anastasia

Programmer
Dec 13, 2000
111
GB
HI I am working with the following code which is within a WML page. What I am doing is taking ifo from a database based on username and password criteria and then displaying their personal details to the user in input boxes this saves a returning user form entering these details again. However if the user has more records in the database then coldfusion will display the input boxes and details twice etc. I only want one record to be displayed only once showing one set of input boxes with the users details displayed only one.

I was thinks of a loop until the first record is found then exist the loop but don't know how to do this in cold fusion.

Here is my code:<CFQUERY name=&quot;login&quot; datasource=&quot;bookings&quot;>
SELECT * FROM tblBookings
</CFQUERY>

<CFOUTPUT QUERY=&quot;login&quot;>
<CFIF #session.username# EQ #Username# AND #session.password# EQ #Password#>

<b>Name:</b><input type=&quot;text&quot; value=&quot;#Name#&quot; name=&quot;name&quot; size=&quot;30&quot; maxlength=&quot;30&quot;/>
<b>Address:</b><input type=&quot;text&quot; value=&quot;#Address#&quot; name=&quot;address&quot; size=&quot;60&quot; maxlength=&quot;60&quot;/>
<b>Card No:</b><input type=&quot;text&quot; value=&quot;#CreditCardNo#&quot; name=&quot;cardno&quot; size=&quot;19&quot; maxlength=&quot;19&quot; format=&quot;NNNNNNANNNNNNNNNNNN&quot;/>
<b>Expiry:</b><input type=&quot;text&quot; value=&quot;#ExpiryDate#&quot; name=&quot;expiry&quot; size=&quot;5&quot; maxlength=&quot;5&quot; format=&quot;NNANN&quot;/>

</CFIF>
</CFOUTPUT>

Any ideas appreciated.

 
Hi Anastasia,

Does this do what you want?

<CFQUERY name=&quot;login&quot; datasource=&quot;bookings&quot; MAXROWS=1>
SELECT * FROM tblBookings
where username = '#session.username#'
and password='#session.password#'
</CFQUERY>
<CFOUTPUT QUERY=&quot;login&quot;>
<b>Name:</b>..... rest of output here ......
</cfoutput>

Let me know if you still have trouble.
GJ
 
GunJack,

Your code above works perfect.

Thank again for your expert help.

Anastasia.
 
GunJack,

Your code above works perfect.

Thanks again for your expert help.

Anastasia.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top