100 likes | 219 Views
ColdFusion :. Code for front page. <cfquery datasource="mydb" name="customers"> select custnumb, custname from customer </cfquery> <html> <title>Customer list</title> </head> <body> <center> <table border> <tr> <th colspan=2> <h1>Customers</h1>
E N D
Code for front page <cfquery datasource="mydb" name="customers"> select custnumb, custname from customer </cfquery> <html> <title>Customer list</title> </head> <body> <center> <table border> <tr> <th colspan=2> <h1>Customers</h1> </tr>
Front page contd. <tr> <th> Name</th> <cfoutput query="customers"> <tr> <td>#custname#</td> <td><A HREF="custupdatefront.cfm?custnumb=#custnumb#">Edit</A> <A HREF="custdelete.cfm?custnumb=#custnumb#">Delete</A> </td> </tr> </cfoutput> <tr> <th colspan=3> <A HREF="custaddfront1.cfm?custnumb=#custnumb#">Add a customer</A> </th> </tr> </table> </center> </body> </html>
Code for updating a customer record <CFIF ParameterExists(Custnumb) IS "NO"> Error! No Customer number was specified! <CFABORT> </CFIF> <CFQUERY datasource = "mydb" name="customers"> select custname, address, balance, credlim, slsrnumb from customer where custnumb=#custnumb# </cfquery> <cfoutput query="customers"> <html> <head> <title>Update customer #Custname#</title> </head> <body> <H1>Update customer #Custname#</H1> <form action="custupdate.cfm" method="POST"> <input type="hiden" name="custnumb" value="#custnumb#"> <br>
Code for update contd. Name: <input type="text" name="custname" size="15" value="#custname#"> <br> Address: <input type="text" name="address" size="25" value="#address#"> <br> Balance: <input type="text" name="balance" size="10" value="#numberformat(balance, "9999.99")#"> <br> Credit limit: <input type="text" name="credlim" size="10" value="#numberformat(credlim, "9999.99")#"> <br> Sales rep number: <input type="text" name="slsrnumb" size="5" value="#numberformat(slsrnumb, 9)#"> <P> <input type="submit" value="Update Customer"> <input type="reset" value="Clear"> </form> </body> </html> </cfoutput>
Update code: template# 2 <cfquery datasource="mydb"> update customer set custname='#custname#', address='#address#', balance=#balance#, credlim=#credlim#, slsrnumb=#slsrnumb# where custnumb=#custnumb# </cfquery> <cfoutput> <html> <head> <title>Customer #custname# updated</title> </head> <body> <h1>Customer #custname# has been updated</h1> /body> </html> </cfoutput>
Code for delete cont. <cfquery datasource="mydb"> delete from customer where custnumb=#custnumb# </cfquery> <html> <head> <title>Employee deleted</title> </head> <body> <cfoutput> <h1>Customer #custnumb# deleted</h1> </cfoutput> </body> </html>