473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Limiting rows of table and appending rows.

In this code I am getting posts from database in table, table displays posts in three columns, now I want to add some jQuery to limit the number of rows and add a button which on clicking appends few rows to table I am not a professional programmer may be something like slice should be used to limit number of rows.

Expand|Select|Wrap|Line Numbers
  1. $sql = "SELECT * FROM posts";
  2. $query = $db->prepare($sql);
  3. $query->execute();
  4.  
  5. <table>
  6. <tr>
  7. <?php do { //horizontal looper?>
  8. <td>
  9. <div>id</div>          
  10. <div>title</div>
  11. <div>body</div>          
  12. <div>date</div>
  13. </td>
  14. <?php
  15. $row = $query->fetch(PDO::FETCH_ASSOC);
  16. if (!isset($nested_List)) {
  17. $nested_List= 1;
  18. }
  19. if (isset($row) && is_array($row) && $nested_List++%3==0) {
  20. echo "</tr><tr>";
  21. }
  22. } while ($row); //end horizontal looper 
  23. ?>
  24. </table>
Oct 26 '15 #1
1 977
Dormilich
8,658 Expert Mod 8TB
it depends if you want to fetch the complete table through PHP and (un)hide parts of it or if you want to dynamically append rows.

for the latter you will need to use AJAX, which tends to be a JavaScript question. additionally, if you limit the results in PHP, you’d do that in SQL using the LIMIT clause (there’s no point fetching thousands of rows when you want to only display ten)
Oct 27 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: UDBDBA | last post by:
Hi All: I have a query which is running against large table. The query: SELECT DSRC_ACCT_ID, ADDR1, ADDR2, ADDR3, CITY, STATE, POSTAL_CODE, COUNT(*) FROM ERD.ADDRESSA GROUP BY DSRC_ACCT_ID,...
0
by: Angel | last post by:
How can I search a datagrid's rows (for a string) and then display only the rows where the item was found? The datagrid's already filled but I don't know where or how if filled up. Thanks.
2
by: shankar | last post by:
Hi all, This is the way to append the rows from one datatable into another with the same schema. Here Temp and Temp1 are the datatables For Each rows As DataRow In tempTable.Rows Temp1...
2
by: duraisridhar | last post by:
Hi all., I am using the Listview control to display my data in table fromat Is there any way ( simple or complex) to Limit the number of rows displayed to avoid the empty rows which is also ...
2
by: Steve | last post by:
Anyway to limit the number of rows that will be shown on a datagrid? Thanks.
1
by: lucky | last post by:
Hello, i am in a problem that i am having a table with 100 rows while i am presenting in report i want to limit rows to be 10 in a page in the report like that i want to get 10 pages .Please say...
1
by: joozeq | last post by:
Hi Is there any way to script a table (with EM or Management studio) along with data contained in the table (rows values)? J
1
by: yakitori | last post by:
I'm very sorry because I suspect that this is the same-old-same-old to some of you. I did search first. With MySQL 5.0.27, I have the query shown below. It *almost* does what I want. In fact it...
1
by: vuyyurus | last post by:
Need help in reading a different word file which has table with rows and columns and write to different word document in certain table with rows and cloumns.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.