Link to home
Start Free TrialLog in
Avatar of evo14sale
evo14sale

asked on

easy points,editing tables value,and access database

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>
Avatar of anandkp
anandkp
Flag of India image

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 ?????????????
Avatar of evo14sale
evo14sale

ASKER

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
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>
ASKER CERTIFIED SOLUTION
Avatar of anandkp
anandkp
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> <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