View Full Version : Get a record and edit it
FlyingL0
06-13-2003, 02:19 PM
How would i got about getting a value from a table have it put into a textbox. Then I can change the information in the text box and then hit a submit button to update the value?
Angelika
06-13-2003, 02:43 PM
Ok!
This is page1.
<%
set Conn=server.CreateObject("ADODB.Connection")
conn.ConnectionString="...."
conn.Open
set RS = server.CreateObject("adodb.recordset")
PID=Request.QueryString("PID")
strSQL="SELECT * FROM Products Where product_id="&PID&""
RS.Open strSQL,Conn
productName = RS( "product_name" )
RS.Close
%>
<html>
<head>
<title>Edit Product Information</title>
</head>
<body>
<p align="center"><b><font face="Arial" color="#000080" size="4">
Edit Product Information</font></b></p>
<form method="POST" action="Product_Edit_Do.asp">
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000080" width="80%" id="AutoNumber1">
<tr>
<td width="65%">
<p align="center"><b><font size="4">Product Information:</font></b></td>
</tr>
<tr>
<td width="65%">
<div align="center">
<center>
<table border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
<tr>
<td width="35%" align="right">
<font face="Arial" size="2"><b>Product Name:</b></font></td>
<td width="65%">
<input type="text" name="Product_name" value="<%=productName%>" size="20">
<input type="hidden" name="ProductID" value="<%=PID%>" size="20">
</td>
</tr>
</table>
</center>
</div>
<p align="center">
<input class="cssbutton" type="submit" value="Update Product"> <br>
</td>
</tr>
</table>
</center>
</div>
<p align="center">
</p>
</form>
</body></html>
-------------------------------------------------
Page2.
<%
set Conn=server.CreateObject("ADODB.Connection")
conn.ConnectionString="...."
conn.Open
set RS = server.CreateObject("adodb.recordset")
ProductID = Request.Form("ProductID")
Product_name = Request.Form("Product_name")
' Specify SQL statement
strSQL = "select * from Products "
strSQL = strSQL + "WHERE product_id= "&ProductID&""
RS.Open strSQL,Conn,3,3
If Not RS.EOF Then
RS.Fields("product_name") = cname
RS.Update
End If
RS.Close
Set RS = Nothing
Conn.close
Conn=Nothing
%>
vBulletin v3.0.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.