Solved

easy points,editing tables value,and access database

Posted on 2003-10-30
8
166 Views
Last Modified: 2013-12-24
hi ya

i have the following data, i would like the user to be able to change the carstatus in the table which will also update the database,can someone plz show me how to do it.
it doesnt matter how its done,either by radio buttons,text etc


<CFQUERY NAME="CarQuery" DATASOURCE="../dno/ser3">
  SELECT * FROM Cars
</CFQUERY>

<TABLE border="2" >
       <TR>
         <TH> Car ID </HT>
         <TH> Car_Status </HT>
       </TR>
     <CFOUTPUT QUERY="CarQuery">  
       <TR align="left">
        <TD>#CarQuery.CarID#</TD>
        <TD>#CarQuery.Car_Status#</TD>
       </TR>
     </CFOUTPUT>
</table>
0
Comment
Question by:evo14sale
8 Comments
 
LVL 17

Expert Comment

by:anandkp
Comment Utility
give the user a form to edit the car status like

<CFQUERY NAME="CarQuery" DATASOURCE="../dno/ser3">
  SELECT * FROM Cars
</CFQUERY>

<TABLE BORDER="2" >
    <FORM NAME="frm" ACTION="updatestatus.cfm" METHOD="post">
     <TR>
       <TH> Car ID </HT>
       <TH> Car_Status </HT>
     </TR>
   <CFOUTPUT QUERY="CarQuery">  
     <TR ALIGN="left">
        <TD>#CarQuery.CarID#<INPUT TYPE="Hidden" NAME="carid" VALUE="#CarQuery.CarID#"></TD>
        <TD><INPUT NAME="carstatus" VALUE="#CarQuery.Car_Status#"></TD>
     </TR>
   </CFOUTPUT>
    </FORM>
</TABLE>

<!--- updatestatus.cfm --->

<CFIF ISDEFINED('CARSTATUS') & LEN(TRIM(CARSTATUS))>
    <CFQUERY NAME="Qry_Update" DATASOURCE="Dsn">
       Update mytable
         set carstatus = <CFQUERYPARAM CFSQLTYPE="cf_sql_varchar" VALUE="#carstatus#">
         where carid = <CFQUERYPARAM CFSQLTYPE="cf_sql_numeric" VALUE="#carid#">
   </CFQUERY>
</CFIF>

<CFLOCATION URL="updatedone.htm" ADDTOKEN="No">

HTH

K'Rgds
Anand

PS : I wonder - the same question was asked by someone ... else ?????????????
0
 

Author Comment

by:evo14sale
Comment Utility
YEH THAT WAS ME,I JUST NEVA GOT NE REPLYS,WELL IF IT WORKS,ILL GIVE U BOTH POINTS IF U SAY THE RIGHT ANSWER
0
 

Author Comment

by:evo14sale
Comment Utility
can u plz show me how to have a couple of radio buttons,so when i click on one,it will update the database.


ps i dont know wat u mean with this,wat is cfqueryparam?

<CFIF ISDEFINED('CARSTATUS') & LEN(TRIM(CARSTATUS))>
    <CFQUERY NAME="Qry_Update" DATASOURCE="Dsn">
       Update mytable
         set carstatus = <CFQUERYPARAM CFSQLTYPE="cf_sql_varchar" VALUE="#carstatus#">
         where carid = <CFQUERYPARAM CFSQLTYPE="cf_sql_numeric" VALUE="#carid#">
   </CFQUERY>
</CFIF>
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 17

Accepted Solution

by:
anandkp earned 120 total points
Comment Utility
cfqueryparam is just a neat way of inserting/updating/deleting values from ur tables.

did u try teh example i posted - it hhas to work for sure

or if u r not able to understand it - show me what code u have & i'll modify it for u !

let em know

K'Rgds
Anand
0
 
LVL 4

Assisted Solution

by:procept
procept earned 120 total points
Comment Utility
<cfqueryparam> actually makes queries more secure, and, sometimes faster.

For the radio buttons: name them all alike and give them different values:
<radio name="carstatus" value="status 1" checked> status 1<br>
<radio name="carstatus" value="status 2"> status 2<br>
<radio name="carstatus" value="status 3"> status 3<br>

Also, make sure that always one radio button is selected, or the variable will not be passed to the next page.

On your action page, #form.carstatus# will hold the value of the selected button.

HTH

Chris
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
> <cfqueryparam> actually makes queries more secure, and, sometimes faster.

Chris is right.  Use Query/Bind Params.  Most DBs are setup for statement caching.  If you don't use Bind Params, each query with a different value will come in as a new query.  If you use Bind Params each value is used and the statement/query is retreived from the DB cache.

CJ
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now