Continuing from an earlier thread, I am now making some progress with my snippet, but would appreciate further advice on how to proceed - I did do some forum searching, but couldn’t really find what I needed.
The basic set-up is now as follows.. I have a database containing a collection of mathematical things (well, they are matroids to be precise, but this is not relevant) along with their properties.
My current set-up for allowing users to interrogate this database is as follows:
(1) A chunk which contains just the plain HTML for a form which allows the user to select a certain combination of properties.. currently just 6 or so properties, but ultimately maybe 20 or so.
(2) A snippet which checks whether the form’s "submit" has been pressed - if not then its default behaviour is simply to display the chunk
http://www.csse.uwa.edu.au/~gordon/index.php?id=18
(3) If so, the snippet extracts the form values, creates an SQL query, does the database look-up and formats the numbers as a table...
(Try it - just hit "count matroids" without changing the defaults and see what you get..)
NOW, I want to add the next step.... each of the numbers in the table should be a link which will allow the user to actually inspect those particular data items... In order to do this, I need to pass the $_POST values from the original form plus two extra values indicating which cell of the table the user clicked to the target document (which I guess could again be the same document).
Again, a number of options present themselves, but I have no feeling for what is the "MODx way" to proceed...
(1) Embed ALL the parameters into each link URL (making them very long)
(2) Use $_SESSION to store the original parameters determining the table, then embed just the extra couple of values into each link...
- is $_SESSION available to my snippets by default, do I need session_start and so on?
(3) Some other way ?
Thanks ..
Gordon
PS Please ignore the styling of the table, I have tied myself in knots with CSS for three different types of table all getting confused, but it will be fixed later. I got overexcited when I learned about how to use thead, tbody and tfoot combined with td and th and then th:first-child to get 7 different individually stylable types of cell.
PPS Is there any way of doing variable interpolation in PHP with multi-dimensional arrays? When I was creating the table, I had things like
"<td>$vals[$i][$j]</td>"
where $vals is the 2d-array of data that I was intending to display.
But it didn’t work, because $vals[$i] got interpolated FIRST - of course its value is "Array" and then the $j got interpolated separately. So my table was full of things like "Array[2]" ... I had to replace my original string with
"<td>" . $vals[$i][$j] . "</td>"