gf05856 Posted August 29, 2006 Share Posted August 29, 2006 Dear,I am looking for a php script that gives me the following output based on the amount of records in a particular mysql table:Fixed output table with 2 columns, 1 column with the numbers 2, 4, 8, 16, 32 .... 1.073.741.824 and a second column that should be filled out with a color based on the amount of records in the mysql table ...Like you see below there are 7 records in the database ( the | should be replaced by a color). If you have any ideas on how to visualise this in a better way, then please be my guest! Also the total amount should be show as an amount like .... Total users: 123456I probably should also consider the fact that when I have 10.000 hits a day on this site that this script is not run 10.000 times back and forward to the database ... but once a day ... and stored.records column to fill up2 |||||||||||||||4 |||||||||||||||8 |||||||||||||1632641282565121.0242.0484.0968.192........ Link to comment https://forums.phpfreaks.com/topic/19062-count-show-amount-of-records-of-a-mysql-table-via-php/ Share on other sites More sharing options...
hitman6003 Posted August 29, 2006 Share Posted August 29, 2006 [code]<?php$query = "SELECT COUNT(*) FROM table";$result = mysql_query($query) or die(mysql_error());$count = mysql_result($result, 0);echo ' <table border="1"> <tr> <th>Number</th> <th> </th> </tr>';for ($i = 1; $i <= 10; $i++) { $n = pow(2, $i); echo ' <tr> <td>' . $n . '</td>'; if ($count >= $n) { echo ' <td style="background-color: red;"> </td>'; } else { echo ' <td> </td>'; } echo ' </tr>';}echo ' </table>';?>[/code] Link to comment https://forums.phpfreaks.com/topic/19062-count-show-amount-of-records-of-a-mysql-table-via-php/#findComment-82464 Share on other sites More sharing options...
gf05856 Posted August 29, 2006 Author Share Posted August 29, 2006 Thanks,It works very nicely.I can certainly use it as a basis and adjust it to my needs.For writing this myself ... it would have taken me .... 1.073.741.824 secondsThanks again. Link to comment https://forums.phpfreaks.com/topic/19062-count-show-amount-of-records-of-a-mysql-table-via-php/#findComment-82476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.