Jump to content

Hello friends, please someone help me.


Forumpost

Recommended Posts

Hello friends. I have a site running, and my site script is php. In members area there a history section where member can see his activities. The problem now is, the history page just keep grows as new activities are taken places, it looks odd as it is keep added in single page. What I want is, I want it create a automated new pages after 25 or 30 history activities like page 1 page 2 so that it looks good. So, please someone help me how to create automated new pages. Thanks.

Edited by Forumpost
Link to comment
Share on other sites

it is sql query which pull your data from database. it should be passed in any query executing function of your database engine or api you are using (eg mysql_query() or mysqli_query()) the above query is just a mock query it should be writen as you need. CALC_FOUND_ROWS is what will let return the found_rows() the total number of rows.

Link to comment
Share on other sites

$get_cashouts = mysql_query("SELECT * FROM cashout_history WHERE usrid=$u ORDER BY cdate"); friend I have taken above code from my script so that you may tell where exactly I can add it. It cashout_history is what I want to make into several pages when it grows.

Link to comment
Share on other sites

$get_cashouts = mysql_query("SELECT CALC_FOUND_ROWS * FROM cashout_history WHERE usrid=$u ORDER BY cdate LIMIT 0,10");

it will get first 10 results. you have to keep track on the page number so that you can determine which offsets of the result you need to get. LIMIT 0,10 here 0 is the offset which means it will start getting rows from row number 0 up to 10..offset will be changed according with the pages. immediately after executing above query you have to use FOUND_ROWS() to get the total number of rows.

SELECT FOUND_ROWS() AS totalRows

Link to comment
Share on other sites

Hello friend, I tried it but I am getting some error response in the place of history Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/theprofi/public_html/members/history.php on line 83 Friend, moreover I don't know where to place "SELECT FOUND_ROWS() as totalRows" should I place it under like this"$get_cashouts = mysql_query("SELECT CALC_FOUND_ROWS * FROM cashout_history WHERE usrid=$u ORDER BY cdate LIMIT 0,10");"SELECT FOUND_ROWS() AS totalRows

Link to comment
Share on other sites

that errors means that you have to valid mysql result resouce passed in mysql_num_rows(). it happends when mysql_query() fails. you have to check why it fails using mysql_error() when mysql_query() fails. SELCT FOUND_ROWS() AS totalRow is different sql query. you have to pass it in different mysql_query() call as you did with your other query.

Link to comment
Share on other sites

Referenceshttp://php.net/mysql_queryhttp://php.net/mysql_num_rowshttp://dev.mysql.com/doc/refman/5.0/en/information-functions.html

Link to comment
Share on other sites

Posted Yesterday, 11:00 PM"that errors means that you have to valid mysql result resouce passed in mysql_num_rows(). it happends when mysql_query() fails. you have to check why it fails using mysql_error() when mysql_query() fails.SELCT FOUND_ROWS() AS totalRow is different sql query. you have to pass it in different mysql_query() call as you did with your other query. ""$get_cashouts = mysql_query("SELECT CALC_FOUND_ROWS * FROM cashout_history WHERE usrid=$u ORDER BY cdate LIMIT 0,10");"$get_cashouts = mysql_query (SELECT FOUND_ROWS() AS totalRows) friend, I really don't know much about coding, please see if above code is right or not. I don't know how to check msql_query error friend.

Link to comment
Share on other sites

You hav to quote it. mysql_query() accepts string as parameter.

[color=#282828][font=helvetica, arial, sans-serif][size=3][font=arial, helvetica, sans-serif][color=#000000]$get_cashouts [/color][color=#666600]=[/color][color=#000000] mysql_query ([/color][color=#000000]"SELECT FOUND_ROWS[/color][color=#666600]()[/color][color=#000000] AS totalRows")[/color][/font][/size][/font][/color]

The links i posted has examples of how to use mysql_error() to debug your code. http://w3schools.com/php/php_select.asp has examples also. . we are not running the codes so there is no way we can know what causing problems. you have to do the initial steps so that we can help you further.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...