Chris Retlich.com | |
Our links: HOME Web-Journal About Me Calendar Movie Reviews, etc. ChrisWare Tip of the week Secure your computer Homework Helpline My Homework Reminder Pictures! Politics! Contests! Trivia! Links Contact me View past newsletters Chat room Site Map Link to my site! Related links: League of Mad Scientists Chris D's Website Five O'Clock Shadow Comic Nathan's Website Neal's Website Sam's Website Austin's Site Best if viewed with: |
Web Journal!chris's journal entry #69; "Back to Work" on 2006-01-05:Previous Next Well, today, I voluntarily went back to work (classes resume on the 11th). While working on various pages on our ASP-based website, I came across this wonderful piece of code: categories="('" & replace(replace(categories,", ",","),",","','") & "')"
Or the same thing made a little less comprehensible:
categories="('"&replace(replace(categories,", ",","),",","','")&"')"
I recognized it as mine own, and it took me a while to decipher what exactally is going on. Well, all you coders out there, enjoy!
For you non-coders, here is what it does: It takes a string (a bunch of letters, numbers; text) and removes the spaces after all commas, then it puts single quotes (') before and after the commas, and then prepends the string with (' and appends ') to the string. This was used to take a comma separated list and converted it into a form usable for an SQL query; in other words, it would convert:
this, that, another thing,and,any, other wordsinto: ('this','that','another thing','and','any','other words') Return (or click back on your browser.) Maintained and copyright 2003-2007 by Chris Retlich, all rights reserved. Last updated on 09/22/22. |