hi Stu,
...
> > Okay I wasn't sure but thought I might need to add > another query statement in. So it would have made it > work except! , I found a new problem with this issue. > > Hopefully I can clearly explain it. > There is a default $orderParam_rsVJ set up. So when > the results are returned to the user things come back > sorted by the default column. > > The problem is when I click the column sorter link and > the page re-loads, it looks like the where array is > getting wiped out, values are gone. I get a "divison > by zero" error. I'm assuming this is becasue the
is this error occurring in mysql or php? could you post the relevant line number or sql statement that causes the error?
> order by statement is issued with no parameters.
what do you mean by '..is issued with no paramters.'? if your sql statements ends in 'ORDER BY ' then that will cause an error (but not div by zero surely?)
Am I right in assuming that when you click a header (order by) link that the page displays the result in the correct order BUT does not include the where clause that was in effect? (my ideas below assume this!)
> > Hope this makes sense and while I think it through > perhaps someone has an idea of remedy.
I assume when the page is first called some filtering values as passed to the page which are used to build the various WHERE clauses, in addition a default order by statement (e.g. 'ORDER BY title'):
the values used to create the WHERE clauses are probably disappearing because you are not doing one of the following (btw doing both is not a good idea):
1. proliferating the WHERE related values in the ORDER BY links - i.e. the column headers need to include all the name value pairs related to the WHERE clauses as well as the name/value pair related to ordering. e.g.: ./foo.php?sortfield=price instead of: ./foo.php?field1=bar&field2=qux&sortfield=price
2. storing the last used filter (i.e. the last given set of WHERE clause related values) in the session, a DB, file*** or whatever in order to remain state - in this case you need to retrieve the values from where they are stored and setup the variables to build the SQL as well as having a mechanism for detecting whether to use new values sent from the browser rather than those already stored.
if you are taking one of the preceding measures then likely it's not doing what its supposed to... in such cases a liberal sprinkling of print_r() statements often help to determine where values are going missing. here is a little func that makes the output nicer to read in a browser:
function pre_print($arg, $returnVal = false) { static $isOnWeb;
if (!isset($isOnWeb)) { $isOnWeb = (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) ? true : false; }
if ($returnVal) { ob_start(); }
echo ($isOnWeb) ? '<pre>' : "\n ---\n"; print_r($arg); echo ($isOnWeb) ? '</pre>' : "\n ---\n";
if ($returnVal) { return ob_get_clean(); } }
-- sorry, I didn't clearly understand your problem, hopefully I haven't completely misunderstood the problem.
rgds, Jochem
***before anybody complains that using files directly to store state related info is per definition bad - consider /tmp mounted in RAM :-).
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php