london77 Posted November 23, 2010 Share Posted November 23, 2010 Hi, i have created a mysql table for account info which stores basic expenses and income I have also account.php page that shows the all transactions 10 transaction (row) per page. there is no problem with that but I like it to show the transactions(entries) per month base. I mean when i open this page i want it to show this month's entries. and when i click previous button i like to see last month's entries. any help will be appreciated. thanks in advance. regards. Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/ Share on other sites More sharing options...
ManiacDan Posted November 23, 2010 Share Posted November 23, 2010 The MySQL functions MONTH() and YEAR() will allow you to filter the date fields. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/#findComment-1138455 Share on other sites More sharing options...
london77 Posted November 23, 2010 Author Share Posted November 23, 2010 here is my code for displaying per page and max 10 per page. I need it to show monthly inmputs, not 10 input(rows) per page. thanks again. // Number of records to show per page: $display = 10; // Determine how many pages there are... if (isset($_GET['p']) && is_numeric($_GET['p'])) { // Already been determined. $pages = $_GET['p']; } else { // Need to determine. // Count the number of records: $q = "SELECT COUNT(acc_id) FROM hesap"; $r = @mysqli_query ($dbc, $q); $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $records = $row[0]; } // End of p IF. // Determine where in the database to start returning results... if (isset($_GET['s']) && is_numeric($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } // Make the links to other pages, if necessary. if ($pages > 1) { echo '<br /><a>'; $current_page = ($start/$display) + 1; // If it's not the first page, make a Previous button: if ($current_page != 1) { echo '<a href="acc.php?s=' . ($start - $display) . '&p=' . $pages . '&sort=' . $sort . '">Previous</a> '; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '<a href="acc.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '&sort=' . $sort . '">' . $i . '</a> '; } else { echo $i . ' '; } } // End of FOR loop. // If it's not the last page, make a Next button: if ($current_page != $pages) { echo '<a href="acc.php?s=' . ($start + $display) . '&p=' . $pages . '&sort=' . $sort . '">Next</a>'; } echo '</a>'; // Close the paragraph. } // End of links section. Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/#findComment-1138469 Share on other sites More sharing options...
trochia Posted November 23, 2010 Share Posted November 23, 2010 Truthfully? Here is what i would do...if I were you a) goto >oscommerce.com b) SEARCH addons > Reports c) You will find one, that has ALL THE ROUTINES needed, that will create a "yearly" in which drills down into "Monthly." "monthly"... d) You can then copy the code...and modify to your DB and Tables...etc...but take the time to read it...also ;-0...then you'll have the concept. Jim Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/#findComment-1138492 Share on other sites More sharing options...
ManiacDan Posted November 23, 2010 Share Posted November 23, 2010 What part of my initial solution was unclear? Nobody is going to do this for you, it will take you 10 minutes to figure it out on your own. Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/#findComment-1138498 Share on other sites More sharing options...
london77 Posted November 23, 2010 Author Share Posted November 23, 2010 Hi Dan, thanks for the reply but I must say im newbie, trying to learn it. So, just putting there Month(); will not be clear for me. I myself tried to do it by creating month arrays but didnt work, tried few other options but couldnt manage it. I am trying. this was the last option for me.Also, im not asking people to do it for me, i need samples to analyse it or explanations to understand it. So, please take it easy. if you dont want to help more than u did, thats ok for me. no need to have a stress. regards. Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/#findComment-1138517 Share on other sites More sharing options...
trochia Posted November 23, 2010 Share Posted November 23, 2010 He was simply conveying: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/#findComment-1138522 Share on other sites More sharing options...
london77 Posted November 24, 2010 Author Share Posted November 24, 2010 thanks again .. great help now dealing with it. Quote Link to comment https://forums.phpfreaks.com/topic/219585-display-pages-monthly/#findComment-1138922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.