Too long in displaying the data in a Web Browser


 
Thread Tools Search this Thread
Top Forums Web Development Too long in displaying the data in a Web Browser
# 1  
Old 01-24-2012
Too long in displaying the data in a Web Browser

this is my another one question as well as my sample program. Because of the big data the gets from the database.,it takes time to display the output in a web browser.,is there any way to display the output as faster as it can..?my time is wasting because of too long to display.Smilie
Code:
 <?php
    // db connection
    $db = "mds_reports";
    
    if($connect = mysql_connect("172.16.8.32", "mds_reports", "password"))
            $connect = mysql_select_db($db);
                else die("Unable to connect".mysql_error());

    $date_from = $_POST['dfrom']; 
    $date_to = $_POST['dto']; 
        
?>
<html>
    <head>
    </head>
        <title>Address Frequency</title>
    <body>
        <h1>Address Frequency</h1>
        <form name="fetching" method="POST" action="AddFrequency.php"></p>
            Date From: <br><input type="text" name="dfrom" id="dfrom"></p>
            Date To: <br><input type="text" name="dto" id="dto"><br /><br />
            <input name="submit" type="submit" value="Go">
        </form>
        <table>
        <table border="2"
        cellpadding="2"
        cellspacing="1"
        style='width:100%;'>
        <tr>
            <th>Restaurant Name</th>
            <th>Region</th>
            <th>City</th>
            <th>Area</th>
            <th>Street</th>
            <th>Building</th>
            <th>Total Orders</th>
            <th>Total Gross Sales</th>
        </tr>
        <?php
            if(isset($_POST['submit']))
{
            echo "Date select from $date_from to $date_to"."</p>";
            $sql = "SELECT restaurant_master.name, RegionMaster.RegionName AS 'region', 
                                CityMaster.CityName AS 'city',
                                DeliveryAddressHistory.Area,
                                DeliveryAddressHistory.Street, 
                                DeliveryAddressHistory.Building,
                                COUNT(mds_orders.OrderDate) AS 'totalorders', 
                                SUM(mds_orders.GrossTotal) AS 'totalgross'

                        FROM mds_orders
                             JOIN DeliveryAddressHistory
                                ON mds_orders.PKID = DeliveryAddressHistory.OrderFKID
                             JOIN CityMaster
                                 ON DeliveryAddressHistory.CityFKID = CityMaster.PKID
                             JOIN RegionMaster
                                 ON CityMaster.RegionFKID = RegionMaster.PKID
                             JOIN restaurant_master
                                 ON mds_orders.RestaurantID = restaurant_master.PKID
     
                        WHERE 
                            mds_orders.OrderDate BETWEEN '".$date_from." 00:00:00' AND '".$date_to." 23:59:59' 
                            AND mds_orders.StatusFKID = 2    

                        GROUP BY restaurant_master.name, RegionMaster.RegionName, 
                            CityMaster.CityName, DeliveryAddressHistory.Area, DeliveryAddressHistory.Street, 
                            DeliveryAddressHistory.Building, mds_orders.StatusFKID";


                $result = mysql_query($sql)
                              or die("SELECT Error: ".mysql_error());
                $num_rows = mysql_num_rows($result);
                                
                $i = 0;
                    if (mysql_num_rows($result) >0) {
                                while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){
                        $csv .= $row['name'].",".
                                        $row['region'].",".
                                        $row['city'].",".
                                        $row['Area'].",".
                                        $row['Street'].",".
                                        $row['Building'].",".
                                        $row['totalorders'].",".
                                        $row['totalgross'].","."<br>";
        ?>
                <tr>
                    <td><?php echo $row['name'];?></td>
                    <td><?php echo $row['region'];?></td>
                    <td><?php echo $row['city'];?></td>
                    <td><?php echo $row['Area'];?></td>
                    <td><?php echo $row['Street'];?></td>
                    <td><?php echo $row['Building'];?></td>
                    <td><?php echo $row['totalorders'];?></td>
                    <td><?php echo $row['totalgross'];?></td>
                </tr>
                </tr>
                </tr>
           <?php
                  }}}
        ?>
            </table<br />
            <form name="export" method="POST" action="Address.php">
            <input type="hidden" name="Address_dfrom" id="data" value="<?=$date_from?>">
        `    <input type="hidden" name="Address_dto" id="data" value="<?=$date_to?>">
            <input type="submit" name="extract" value="Extract">
    </form>
    </body>
</html>


thanks in advanced. Have a great day ahead! Smilie

Last edited by jim mcnamara; 01-24-2012 at 09:20 AM..
# 2  
Old 01-24-2012
Your database interface is the first place to look. Your sql is not bad or good, it all depends on the existence of indexes on the selected items and other metadata.
Some types comparisons force the parser to turn off index use as well.

Try using a mysql query profiler tool on your sql as it runs:

Log Monitor 0.2 - MySQL profiler + generic file monitor - SharewarePlaza
# 3  
Old 01-24-2012
If the report does not have to contain up to the minute data, you might consider generating a consolidated table once a day (or every 8 hours?) that simplifies the query into just finding the starting row, and reading down to the ending row, and rolling up the totals.
# 4  
Old 01-24-2012
actually the range of data that I am getting is for 1 month because I need to get the sum up of totalgross in 1 month. I also try in just one day but still it takes time to display the output. What more if it's in 1 month..? What should I do..? :|
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to input data from a file into a web browser search engine?

Hi, I have a list of strings in a file on my terminal. I would like to input each line into a search engine and press the search button within a web browser. How can this be done? I am using firefox Thanks (1 Reply)
Discussion started by: cyberfrog
1 Replies

2. Web Development

What is Your Favorite Web Browser?

OK, please vote on your favorite web browser and comment why! Only currently supported browers please! Thanks. PS: I am a big FireFox fan. FireFox add-ons rock! (61 Replies)
Discussion started by: Neo
61 Replies

3. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

4. What is on Your Mind?

The Dillo Web Browser

Hello, Have you all noticed that the Dillo web browser always reports bugs just about on every web page. Richard Stallman's Personal Page However some, but not many have none. cheers (2 Replies)
Discussion started by: nigelc
2 Replies

5. Solaris

Web browser not opening

On clicking on my WEB BROWSER . no window is appearing , only a dialog box appearing with named "ALERT" any nothing else. What is browser package name , which is by default in Solaris 10 (3 Replies)
Discussion started by: kush singh
3 Replies

6. Shell Programming and Scripting

Displaying text file in browser - perl

Don't know why this didn't get posted before but... I am having issues displaying a log file in the browser using perl and I can't get it to display at all, All i get is WHITE (blank page). I have proper permissions in my cgi-bin directory and everywhere else. So I know that's NOT the issue. ... (3 Replies)
Discussion started by: Dabheeruz
3 Replies

7. Shell Programming and Scripting

Displaying text file in browser - perl

I am having issue dispalying text file in browser using perl. Here is my code: #!/usr/bin/perl print "content-type: text/html \n\n"; open (FH , "access.log") || die "Blah $!"; while (<FH>) { print $_ ; } I have correct permissions and everything. The weired thing is when I... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

8. UNIX for Dummies Questions & Answers

Displaying VERY long process names with ps -ef

Hi, I'm trying to display all process on an AIX server with the string SLRServer in them. Normally "ps -ef|grep SLRServer" would be sufficient, however in this instance the process name is enormous and the part which contains this string has been truncated, as you can see in the example below ... (8 Replies)
Discussion started by: m223464
8 Replies

9. UNIX for Dummies Questions & Answers

Web browser and web server for Unix

Hi there all I am looking for both a web browser as well as a web server (Ie. Netscape Fasttrack) that will run on HPUX 10. If you know where I can get these free via FTP, please contact me as soon as possible!! Thanks, Mark (1 Reply)
Discussion started by: mleathers
1 Replies
Login or Register to Ask a Question