View Full Version : Streamlining code and variable passing...

08-04-2007, 05:54 PM
First off, thanks for having a nice easy to read coding forums. Greatly appreciated.

My web based program can be seen here: http://www.squirrelpf.com/~turbocalc/beta/

Having never really programmed much in php, javascript, or mysql, this was quite the challenging task and has taken me a few weeks.

As you can see, I allow people to hot link either their configuration or the image that is generated on the fly. Of course it uses an insanely long URL because I pass all the data thru it. What is worse, is the series of strings I wrote just to write that data to those fields.

So how can I streamline that part? I would love to have that entire thing down to a short burst of data. Is that possible and worth it? Would it require a large bit of recoding?

Also if anyone sees any suggestions for streamlining my javascript, I would be very happy!


08-04-2007, 06:40 PM
one method would be to store saved configs in a database table, along with a unique id, and use that id as the request-parameter, performing a lookup on the database to pull out the values.

Another method would be to compress the key-value pairs in some way that makes them shorter, but in such a way to can reverse the compression when re-populating the form. Rather than:

(taking just the first bit)

you could get your code to output this as

or even more simply
and have your code know that a = version (and so on).

this could be shortened a litle bit further as:

and your code would split the param on |, and know that the first one is the version, the second the power (and so on).