Gaining facility with php

Jun 21, 2010 23:49

I'm getting to the point where I can actually have an idea and make it happen even if it's not just a variation on one of the projects in the books I've been working through. Friday i decided it would be cool to have a series of checkboxes, one for each day of the week, then take the checked values and  have the day names output as a string with ( Read more... )

php, scripting

Leave a comment

Comments 12

literalman June 22 2010, 11:35:16 UTC
Does PHP allow "SELECT vegetables FROM refrigerator WHERE type = ? AND status <> ?

Reply

emdiar June 22 2010, 15:00:26 UTC
I actually jumpd over to SQL for that part. I should have commented that line with a note to that effect.

Reply

literalman June 22 2010, 16:16:23 UTC
Actually, I was interested as to whether PHP allows parameterized SQL (i.e. bind variables) --  for efficiency, to sidestep backslash hell, and to avoid SQL injection attacks. Thanks

Reply

emdiar June 22 2010, 17:38:43 UTC
I see. This is how much of a noob I am.

As I understand it, "bind variables" basically means using variables in a SQL query so the query can be reused without being rewritten. Is that about right? If so, then yes.

Reply


digitalsidhe June 22 2010, 16:28:10 UTC
It doesn't seem like much, but hey, I'm a noob.

Actually, it sounds like a great learning exercise: A step or two above trivial, but not so difficult that it takes days and days of work. It solves a real-world problem, rather than some abstract puzzle, and it's something that can be solved with some intelligence and effort, but doesn't require some creative "A-ha!" realization. I like it!

While reading, I was expecting you to say it should print out a list of weekday names with "and" in the right place, which is a problem I wrote a function for a long time back. Interpolating a list with "through" is a different problem, and one I'm going to have to ponder a bit once the caffeine kicks in.

Reply

emdiar June 22 2010, 17:33:21 UTC
I figure if I'm going to be teaching myself I might as well also end up with some useful code. And I'm glad to report that it did not in fact take days and days, although I am looking forward to being able to do something like this in a lot less time than this took.

When I implement this on the site I'm making it for I'm going to use abbreviated day names, and an em dash instead of "through." It's for a part of a site that has space limitations, so I'm trying to shorten the display of the list of days the client's business is open.

Reply

emdiar June 22 2010, 17:42:27 UTC
I'm very interested in seeing other methods of solving the problem, partly to learn other ways of doing things and also to learn whether I'm doing something inefficiently or in a manner that is not secure. If you come up with a solution I'd love to compare notes. I'll send you my script if you'd like to see it.

Reply

digitalsidhe June 22 2010, 23:49:55 UTC
Why don't I take a whack at it without first seeing your version, just so it doesn't bias me?

Reply


Leave a comment

Up