0
                    <div id="rightContent">
                    <div id="contentBox" class="right">
                        <div id="contentPadding" style="padding: 10px 10px 5px 10px;">
                            <div id="slickTitle" class="hotelStat">
                            <?php $userReg = mysql_num_rows(mysql_query("SELECT * FROM users")); ?>
                                <?php echo $userReg; ?> Registered Users
                            </div>
                            <div id="slickTitle" class="hotelStat">
                            <?php $totalFurni = mysql_num_rows(mysql_query("SELECT * FROM furniture")); ?>
                                <?php echo $totalFurni; ?> Total Furniture
                            </div>
                            <div id="slickTitle" class="hotelStat">
                            <?php $totalRooms = mysql_num_rows(mysql_query("SELECT * FROM rooms")); ?>
                                <?php echo $totalRooms; ?> Rooms Created
                            </div><br clear="all" />
                        </div>
                    </div>
                </div>

Was wondering is there a better way of doing the above to select the total amount id's per table to gather statistics ? Also wondering how can I make it display things like this?

35k instead of 35000 ?

2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by Avicii
0
SELECT COUNT(*) AS count FROM users

This query will get only one row, you can use mysql_fetch_assoc to get it. Performance will be better. You can even join the three queries into one for better performance (or use a VIEW).

0

<?php $userReg = mysql_num_rows(mysql_query("SELECT COUNT(*) AS count FROM users")); ?>

Only returns 1 user could you help me with the whole code? I suck personally at coding. That is why I'm asking for help :(

0

Ended up with the following any help with cleaning it up?

                    <div id="rightContent">
                    <div id="contentBox" class="right">
                        <div id="contentPadding" style="padding: 10px 10px 5px 10px;">
                            <div id="slickTitle" class="hotelStat">
                            <?php $result = mysql_query("select count(1) FROM users");
                                $row = mysql_fetch_array($result);
                                $totalUsers = $row[0];
                                echo " " . $totalUsers; ?> Registered Users
                            </div>

                            <div id="slickTitle" class="hotelStat">
                            <?php $result = mysql_query("select count(1) FROM furniture");
                                $row = mysql_fetch_array($result);
                                $totalFurniture = $row[0];
                                echo " " . $totalFurniture; ?> Total Furniture  
                            </div>

                            <div id="slickTitle" class="hotelStat">
                            <?php $result = mysql_query("select count(1) FROM rooms");
                                $row = mysql_fetch_array($result);
                                $totalRooms = $row[0];
                                echo " " . $totalRooms; ?> Rooms Created
                            </div><br clear="all" />
                            </div>
                        </div>
                    </div>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.