0

I need to display via a html page the number of rows within my sql database table. with javascript. I cant use php as the frontend of the template is all html.

The admin section of my site uses php and uses the following code to get the number or rows within my channel table.

<?php $qry="select * from channel";
                    $res=mysqli_query($con,$qry) or die(mysqli_error($con));
                    $rowcount=mysqli_num_rows($res);

                        ?><?php echo $rowcount; ?>

How can I reproduce the same using html and javascript.

Thanks

2

1 Answer 1

0

What will you count in HTML? If all rows are displayed as HTML table rows, you could count them. Otherwise you couldn't count rows in a SQL-table to which you don't have access from the frontend.

Counting rows of an HTML table with id="mytable" would look like this:

var num_rows = $('table#mytable tr').size();
Sign up to request clarification or add additional context in comments.

1 Comment

sorry for the the long reply time. I got this issue fixed. Thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.