On a page, I have multiple instances of the below code, which grabs snippets of info depending on the ID. If possible, I simply need a way to count exaclty how many times the below code is used on that page. So if I pasted that code 17 times with 17 different IDs, I need a way to generate that total number (17).
I've tried adding things like $count++ to every instance and then getting the total with $count, but that only works if the total is below all the instances. But in this case I need the total at the top of the page. Any ideas?
<? $rs= mysql_query("select id from Files $order");
while ($row= mysql_fetch_array($rs)) {
$idnumber = 2696;
require("row.php");
} ?>
If by "page" you mean HTML page, you could just include something like:
<div style="display:none" class="count-me"></div>
after each closing ?>. Then use jQuery to count the number of times it sees that class and output that somewhere on your page:
<script>
$('#id-of element-where-you-output-number').text( $('.count-me').length );
</script>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments