Solved

easy points,editing tables value,and access database

Posted on 2003-10-30
8
168 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
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.

 
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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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