Supprimer n'importe kel champs de n'importe kel table !! :)

Contenu du snippet

BOn c un chti code mais ki sert bien pour faire la partie ADMIN de votre site ou ...

Source / Exemple :


<%
' Connection
suppr = request.Querystring("val")
if suppr = "" then
suppr = request.form("suppr")
end if
%>
<HTML>
<BODY>
<FONT SIZE=1><BR></FONT>
<TABLE WIDTH=95% HEIGHT=100% CELLPADDING=1 CELLSPACING=0>
<TR>
<TD WIDTH=20></TD>
<TD VALIGN=Top BGCOLOR=#000000>
<TABLE WIDTH=100% HEIGHT=100% CELLPADDING=1 CELLSPACING=0><TR>
<TD BGCOLOR=#FFFFFF vAlign=top>
<TABLE WIDTH=100% BORDER=0 CELLSPACING=4>
<TR>
<TD WIDTH=100% vAlign=Top><BR>
<TABLE height=2 cellSpacing=0 cellPadding=1 width="100%" bgColor=#004080 border=0>
<TBODY>
<TR>
<TD>
<TABLE height=20 cellSpacing=0 cellPadding=1 width="100%" bgColor=#EFE0DC border=0>
<TBODY>
<TR>
<TD><FONT SIZE=1 FACE=Verdana color=#990000><B>&nbsp;[.:SUPRESSION:: ] </FONT>
</TD></TD></TR></TBODY></TABLE></TD></TD></TR></TBODY></TABLE><BR>
			  			  <%
response.write("<FORM ACTION='suppr.asp' METHOD=POST>")
sSQL = ""
sSQL = sSQL & "SELECT * FROM " & suppr & ""
Set SuprrRec = Server.CreateObject("ADODB.RecordSet")
SuprrRec.CursorLocation = adUseClient
SuprrRec.Open sSQL, CONN, adOpenDynamic, adLockPessimistic			  
if Request.Form("delete") <> "" then
   			  SuprrRec.AbsolutePosition = Cint(Request.Form("delete"))
SuprrRec.Delete
response.write("voilà c fait  !! Retourne à la page SUPPRESSION<a href='suppr.asp'>SUPPRESSION</a>")
Else
Response.write("<TABLE BORDER=1 bordercolor='#990000' width='100%'>")
response.write("<INPUT TYPE='submit' VALUE='Supprimer' class=InputSubmit>")
response.write("<INPUT TYPE='hidden' NAME='suppr' VALUE='" & suppr & "'>")
Response.write("<TR>")
for i = 0 to SuprrRec.Fields.count -1
Response.write("<TH>::" & SuprrRec(i).Name & "::</TH>")
next
Response.write("<TH>::Supprimer::</TH>")
Response.write("</TR>")
while not SuprrRec.EOF
Response.write("<TR>")
for i = 0 to SuprrRec.fields.count -1
Response.write("<TD>" & SuprrRec(i) & "</TD>")
next
Response.write("<TD><input type=radio name=delete value=" & SuprrRec.AbsolutePosition & "></TD>") 
Response.write("</TR>")
SuprrRec.MoveNext
wend
response.write("</TABLE>>")
response.write("</FORM>")
%>
<% End If%>
</FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD></TR></TABLE>
</BODY>
</HTML><%
CONN.Close 
Set CONN = nothing  %>

Conclusion :


Le code est pas encore super mais je pense k'on peut l'améliorer !!
NB : pour appeler la page il faut obligatoirement :
suppr.asp?val={nom de la table} :)

c tout
@++ et bonn' prog'
pi0up51
www.infobox51.fr.st

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.