[an error occurred while processing this directive] Edit or Delete Address entries
Make your own free website on Tripod.com
Viewing address entries for edit/delete: :
Home
Log out
 

<% function displayRecords(SEARCH_FILTER,CONTENT){ pRecordSet=Server.CreateObject("adodb.RecordSet"); var pText=""; var pRecordCount=0; var counter=0; var search_by_letter_param=""; var rowColor=""; var psql=""; var pPage=parseInt(pRequests["pPage"]) || 1; pText+=""+showAlphabetList('edit.asp')+"

"; switch(SEARCH_FILTER){ case "VIEW_BY_LETTERS": pText+=""+showSearchBox('edit.asp',"")+"
"; psql="SELECT * FROM pAddressTable WHERE first_nam" +"e LIKE '"+CONTENT+"%' ORDER BY serial ASC"; search_by_letter_param="&action=viewbyletter&letter="+CONTENT; break; case "VIEW_BY_SEARCH_WORD": CONTENT=filter_content(CONTENT); pText+=""+showSearchBox('edit.asp',CONTENT)+"
"; psql="SELECT * FROM pAddressTable WHERE " +"first_name LIKE '%"+CONTENT+"%' OR last_nam" +"e LIKE '%"+CONTENT+"%' OR email LIKE '%"+CONTENT+"%' " +"OR phone LIKE '%"+CONTENT+"%' OR nick_name LI" +"KE '%"+CONTENT+"%' OR address LIKE '%"+CONTENT+"%' O" +"RDER BY serial ASC"; search_by_letter_param="&action=search&q="+CONTENT; break; default: pText+=""+showSearchBox('edit.asp',CONTENT)+"
"; psql="SELECT * FROM pAddressTable ORDER BY SERIAL"; break; } pRecordSet.Open(psql,db); pRecords={ // Recordset objects serial : pRecordSet.fields("serial"), // Object Array (collection) fname : pRecordSet.fields("first_name"), lname : pRecordSet.fields("last_name"), email : pRecordSet.fields("email"), phone : pRecordSet.fields("phone"), nick : pRecordSet.fields("nick_name"), address : pRecordSet.fields("address") }; if((pRequests["pAction"]=="search") && (CONTENT.length==0)){ pText+=""+showSearchResult("Too short phrase to search. Try larger phrase."); return pText; } if(pRecordSet.EOF){ pText+=""+showSearchResult("No results found in the address book regardin" +"g  "+CONTENT+" <\/font><\/span>"); } else{ pRecordSet.moveFirst(); while(!pRecordSet.EOF){ // Counting total records as recordset.recordCount() pRecordSet.moveNext(); // does not work in JScript/asp counter++; } switch(pRequests["pAction"]){ case "search": pText+=""+showSearchResult(counter+" result[s] found in the ad" +"dress book regarding   "+CONTENT+"  <\/span" +"><\/font>


"); break; case "viewbyletter": pText+=""+showSearchResult(counter+" result[s] found in the ad" +"dress book starting first name with &n" +"bsp;"+CONTENT+" <\/b><\/span><\/font>

<\/p>"); break; default: break; } var pTotalPages=Math.ceil(counter/pViewPageSize); pRecordSet.moveFirst(); pRecordSet.move(pViewPageSize*(pPage-1)); pText+="\n\n"; while((pRecordCount[ "+pRecords["serial"]+" ]<\/td>\n\n\nDel\n" +"\n\n\n\n"+showPageNavigator(counter,pPage,pTotalPages,'edit.asp',search_by_letter_param)+""; pRecordSet.close(); } return pText; } function showEdit(){ var pText=""; pRecordSet=Server.CreateObject("adodb.RecordSet") var pPage=parseInt(Request.queryString("page")) || 1; psql="SELECT * FROM pAddressTable WHERE serial="+pRequests["pID"]; pRecordSet.open(psql,db); pRecords={ // Recordset objects serial : pRecordSet.fields("serial"), // Object Array (collection) fname : pRecordSet.fields("first_name"), lname : pRecordSet.fields("last_name"), email : pRecordSet.fields("email"), phone : pRecordSet.fields("phone"), nick : pRecordSet.fields("nick_name"), address : pRecordSet.fields("address") }; pText="\n

R" +"ecord ID<\/td>\nEdit<\/td>\nDelete<\/td>Name<\/t" +"d>Email<\/td>
\nEdit\n"+pRecords["fname"]+" "+pRecords["lname"]+"<\/td>\n"+pRecords["email"]+"<\/td>\n<\/t" +"r>\n"; pRecordSet.MoveNext(); pRecordCount++; } pText+="
\n
\n" +"
\n\npAddressbook - Edit Adress<\/b" +">\n<\/font><\/td><\/tr><\/table>


\n\n\n" +"\n\n\n\n\n\n\n\n"+"\n\n\n\n\n\n\n\n\n
ID : "+pRecords["serial"]+"<" +"input type=\"hidden\" name=\"id\" value=\""+pRecords["serial"]+"\">
First Name:\n\n L" +"ast Name: \n
Email :: \n\n Phone Number ::\n
Nick Name ::\n   (without spaces)\n
Address ::\n
\n\n<\/a>       <\/a>\n" +"
\n
\n\n" return pText; } function updateRecord(){ for(var i in pRequests){ pRequests[i]=pRequests[i].replace(/'/g,"''"); // Avoid SQL bad character ERROR pRequests[i]=pRequests[i].replace(/\|/g,""); } var pConn=Server.CreateObject("adodb.connection"); pConn.open(db); var pSQL=""; pSQL="UPDATE pAddressTable SET " +"first_name='"+pRequests["pFName"]+"', " +"last_name='"+pRequests["pLName"]+"', " +"email='"+pRequests["pEmail"]+"', " +"phone='"+pRequests["pPhone"]+"', " +"nick_name='"+pRequests["pNick"]+"', " +"address='"+pRequests["pAddress"]+"' " +" WHERE serial="+pRequests["pID"]+""; pConn.execute(pSQL); pConn.close(); pConn=null; pSQL=""; Response.write(showMessage("Update Message","A record updated wi" +"th ID "+pRequests["pID"]+" and the name was : "+pRequests["pFName"]+"" +" "+pRequests["pLName"]+"

Click here to ge" +"t back to edit Page")); } function deleteRecord(){ var pConn=Server.CreateObject("adodb.connection"); pConn.open(db); pSQL="DELETE FROM pAddressTable WHERE serial="+pRequests["pID"]; pConn.execute(pSQL); pConn.close(); pConn=null; pSQL=""; Response.write(showMessage("Delete Message","A record deleted wi" +"th ID "+pRequests["pID"]+"

Click h" +"ere to get back to edit Page")); } function searchRecords(){ pSearchText=""; } var pRequests={ pID : String(Request("id")), pAction : String(Request("action")), pFName : String(Request("fname")), // Requests retrieved from pLName : String(Request("lname")), // an Object Array or Collection pEmail : String(Request("email")), // for easy navigation. pPhone : String(Request("phone")), // The items are invoked when pNick : String(Request("nick")), // they are called pAddress : String(Request("address")), pPage : String(Request("page")), pQuery : String(Request("q")), pLetter : String(Request("letter")) }; switch(pRequests["pAction"]){ case "delete": deleteRecord(); break; case "edit": Response.write(showEdit()); break; case "editrecords": updateRecord(); break; case "search": Response.write("" +""+displayRecords("VIEW_BY_SEARCH_WORD",pRequests["pQuery"])+""); break; case "viewbyletter": Response.write(displayRecords("VIEW_BY_LETTERS",pRequests["pLetter"])); break; default: Response.write(displayRecords()); break; } %>