Basically, i have a table with a ciolumn for categories. Without makign anew page, i am using the if function to list all the rows of a particular column. Its going on alright but when it comes to paging the results, it returns the total pages of the entire table and not that particular column and if you clikc on any page number, it moves to a page with all the categories instaead of remaining on the same category. Basically i am trying to do something on these lines
mysql_query("select count(*) from table where cat=$cat");
the cat is variable and can be defined as $_GET, but its not working. Can anyone help me please? I need to paginate my results wiuth respect to columns in the table.
There are no quotes around $cat which could cause problems (also I hope you are sanitizing the variable before you are using it):-
PHP Code:
mysql_query("select count(*) from table where cat='$cat'");
also try echoing out the query to ensure that it looks right and try that query in phpmyadmin to ensure that it has the desired effect.
The code is php as the mysql_query is a php function. There is no reason to use a variable for the query nor any reason to concatanate the query. Your code will have the same affect as what he already has.
Last edited by filth@flexiwebhost : 04-08-2006 at 01:59 PM.
when you open the page, by default it does not have a ?cat page, it simply opens the .php page, so if i set $cat here, how can i make it point to all categories when $cat == ""? First porblem still not resolved
__________________
New mobile content website coming soon