A rabbit hole to China

R seems to have weathered the changes in gambling legislation [1] and called for some help on a website he's been working on. It involves moving a site from an undocumented overwrought PHP framework to a documented overwrought PHP framework (which is mostly done) and one of the last bits to do is the integration of a questionnaire.

How hard could it be to integrate a questionnaire?

Oh, it's 18,449 lines of non-integrated PHP code.

Lovely.

So I'm going through the code and see a bunch of stuff like this:

>
```
<input
type="checkbox"
name="followanswer_7"
id="followanswer_7"
value="1"
onclick="checkbox_selected_fu(7)"
>
```

So my guess is not only is it 18,449 lines of PHP, but there's probably a nice dose of AJAXy goodness (Asynchronous JavaScript and XML) [2] thrown in. Curious as to what checkbox_selected_fu() might be doing, I search for its definition.

Deep in a PHP function I find the following:

>
```
echo 'function checkbox_selected_fu(followup_questionsid) {'.b;
$qry = "SELECT * FROM followup_questions WHERE conditions='yes';";
```

If I thought 18,499 lines of PHP code was lovely, this is just peachy keen! Constructing JavaScript on the fly from PHP and SQL (Structured Query Language)! Woot! Please sir, can I have some more?

Update a few hours later …

Why yes, I can have more!

That JavaScript being generated on the fly by PHP and SQL? Turns out it's generating HTML (HyperText Markup Language) on the fly.

I can't tell you how thrilled I am to learn that.

I talked to R, and we both agreed that it would probably be best to turn the questionnaire into something that runs as standalone as possible. Which we think is doable since the questionnaire was one of the last things done under the undocumented overwrought PHP framework and even the developers were getting tired of the framework (which should tell you something about the framework) and just wrote the questionnaire as quickly as possible. Which probably explains the code quite a bit …

[1] /boston/2006/10/10.1

[2] http://en.wikipedia.org/wiki/Ajax_(programming)

Gemini Mention this post

Contact the author