Entry tags:
Coding HEEEEEEEELP!!
ETA: You can ignore this now. I'm wiping the slate clean and restarting.
If you're not familiar with coding, PASS ON BY. This will only confuse you.
Right. So I have SQL query results that I'm attempting to write to the screen with checkboxes such that child categories are underneath their parent categories, and so that they display as three across, then start a new table row. I'm now thoroughly confused and mixed up and at the point where I'm not sure why it works as well as it does, much less as to why the parts that are screwing up are screwing up.
i is the counter I'm using to make the table cells. i=3, close this row, start another one.

[edit] The b0rked table code that it produces is here: http://www.magatsu.net/pic2/SQL-table-code.txt
You can see the problem - that final series of table cells ranging from Communication through Sociology all belong under Social Sciences. The script thinks they're child categories, and thinks that their parent category is Social Sciences, it's just that my counter is SOMEHOW getting off for them. It has to do with the placement of the counter in the script, and hence my logic, not the records themselves, as the categories that are affected change as I move the counter around.
I probably need to start over from scratch in building this table, and there's probably a far easier way to do it, but I'm too solidly in CONFUSION HELL right now to be capable of that at the moment.
The query results:

The code in question (please don't laugh): http://www.magatsu.net/pic2/SQL-code.txt
If you're not familiar with coding, PASS ON BY. This will only confuse you.
Right. So I have SQL query results that I'm attempting to write to the screen with checkboxes such that child categories are underneath their parent categories, and so that they display as three across, then start a new table row. I'm now thoroughly confused and mixed up and at the point where I'm not sure why it works as well as it does, much less as to why the parts that are screwing up are screwing up.
i is the counter I'm using to make the table cells. i=3, close this row, start another one.

[edit] The b0rked table code that it produces is here: http://www.magatsu.net/pic2/SQL-table-code.txt
You can see the problem - that final series of table cells ranging from Communication through Sociology all belong under Social Sciences. The script thinks they're child categories, and thinks that their parent category is Social Sciences, it's just that my counter is SOMEHOW getting off for them. It has to do with the placement of the counter in the script, and hence my logic, not the records themselves, as the categories that are affected change as I move the counter around.
I probably need to start over from scratch in building this table, and there's probably a far easier way to do it, but I'm too solidly in CONFUSION HELL right now to be capable of that at the moment.
The query results:

The code in question (please don't laugh): http://www.magatsu.net/pic2/SQL-code.txt

no subject
Having spent five minutes working through the loop, it looks to me like the last column of cells can only ever contain 1 child item. The first time you go through the loop for this column (when i=2), it hits the 'i= i+1' line (as the parent item is different to the last parent). So i is now 3, and it writes the parent item and the first child into the cell. BUT then it goes back round the for loop again - and this time i==3, so it immediately makes a new line and sets i to 0.
I think what you want is for the test on i to be "make a new line if i=4" -- that is, one greater than the (one-based) index of the last column.
Basically, I think you've got a fencepost error! (off by one in your index count)
no subject
if i = 4 then
response.write "" & VbCrLf & "
no subject
no subject
Thank you! I now have a new place to look (or something to avoid if I start from the beginning again).
no subject
I'd take a close look at the code in this if statement:
if parentID = parentIDFormer then
...
Can you get it to print some more debug info in the cell every time it prints a child item - the parent id and the parentidformer?
no subject
no subject
In any case, the general gist was that examining the table source for 'Social Sciences' and comparing it to the previous category, we can see that extra tags are getting inserted because the code hits i=3, plonks down the end row code, sets i=0, carries on with the next item, and then hits i=0 again and plonks down [tr][td valign='top'] (angle brackets replaced to make LJ ignore them). The combination of which seems to cause weird formatting in the table.
I'm running up against the limits of my SQL table formatting knowledge now... :-)
no subject
I'm cleaning the slate and re-starting from my simple vertical list of parent/child checkboxes, to see if I can't redo it better and simpler. I think my biggest problem was in knowing when to close a table cell and when not to.
And to answer a question in your previous comment that's not in this one: no, I didn't really want that first blank column in there, but for some reason it seemed to make sense at the time. I can't explain it now. :D
no subject