Solved

easy points,editing tables value,and access database

Posted on 2003-10-30
8
169 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
ID: 9655818
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
ID: 9655842
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
ID: 9655867
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
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)

 
LVL 17

Accepted Solution

by:
anandkp earned 120 total points
ID: 9655916
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
ID: 9656193
<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
ID: 9658861
> <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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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