Remove duplicate data in php


 
Thread Tools Search this Thread
Top Forums Web Development Remove duplicate data in php
# 1  
Old 01-12-2012
Data Remove duplicate data in php

helllo there.. I really need your help..

I have my sample program like this..
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> 
     
    <body> 
        <h1>Sales Per Sales Frequency Bracket</h1>
        <form name="fetching" method="POST" action="Sales.php"> 
            Date From: <input type="text" name="dfrom" id="dfrom"></p>
            Date To: <input type="text" name="dto" id="dto"></p>
            <input type="submit" name="go" value="Go"></p>
            <input type="submit" name="extract" value="Extract">
        </form> 
        <table> 
        <td><?php echo $row['code'];?></td> 
                    <td><?php echo $row['name'];?></td> 
                    <td><?php echo $row['less100'];?></td> 
                    <td><?php echo $row['less200'];?></td> 
                    <td><?php echo $row['less300'];?></td> 
                    <td><?php echo $row['less400'];?></td> 
                    <td><?php echo $row['less500'];?></td> 
                    <td><?php echo $row['less600'];?></td> 
                    <td><?php echo $row['less700'];?></td> 
                    <td><?php echo $row['less800'];?></td> 
                    <td><?php echo $row['less900'];?></td> 
                    <td><?php echo $row['less1k'];?></td> 
                    <td><?php echo $row['gtr1k'];?></td> 
                    <td><?php echo $row['total'];?></td> 
        <!--<tr> 
            <th>Restaurant Code</th> 
            <th>Restaurant Name</th> 
            <th>100 & BELOW</th> 
            <th>101-200</th> 
            <th>201-300</th> 
            <th>301-400</th> 
            <th>401-500</th> 
            <th>501-600</th> 
            <th>601-700</th> 
            <th>701-800</th> 
            <th>801-900</th> 
            <th>901-1000</th> 
            <th>1001 & ABOVE</th> 
            <th>TOTAL TC</th> 
        </tr>--> 
        <?php 
            if(isset($_POST['go'])){ 
                $sql = "SELECT restaurant_master.code, restaurant_master.name, 

                            COUNT(CASE WHEN mds_orders.GrossTotal < '100' 
                                THEN 1 END) AS less100, 
     
                            COUNT(CASE WHEN mds_orders.GrossTotal >= '100' AND mds_orders.GrossTotal < '200' 
                                THEN 1 END) AS less200, 

                            COUNT(CASE WHEN mds_orders.GrossTotal >= '200' AND mds_orders.GrossTotal < '300' 
                                THEN 1 END) AS less300, 
     
                            COUNT(CASE WHEN mds_orders.GrossTotal >= '300' AND mds_orders.GrossTotal < '400' 
                                THEN 1 END) AS less400, 

                            COUNT(CASE WHEN mds_orders.GrossTotal >= '400' AND mds_orders.GrossTotal < '500' 
                                THEN 1 END) AS less500, 
         
                            COUNT(CASE WHEN mds_orders.GrossTotal >= '500' AND mds_orders.GrossTotal < '600' 
                                THEN 1 END) AS less600, 
     
                            COUNT(CASE WHEN mds_orders.GrossTotal >= '600' AND mds_orders.GrossTotal < '700' 
                                THEN 1 END) AS less700, 
             
                            COUNT(CASE WHEN mds_orders.GrossTotal >= '700' AND mds_orders.GrossTotal < '800' 
                                THEN 1 END) AS less800, 
     
                            COUNT(CASE WHEN mds_orders.GrossTotal >= '800' AND mds_orders.GrossTotal < '900' 
                                THEN 1 END) AS less900, 
     
                            COUNT(CASE WHEN mds_orders.GrossTotal >= '900' AND mds_orders.GrossTotal < '1000' 
                                THEN 1 END) AS less1k, 

                            COUNT(CASE WHEN mds_orders.GrossTotal >= '1000' 
                                THEN 1 END) AS gtr1k, 
     
                            COUNT(mds_orders.GrossTotal) AS total 

                            FROM mds_orders 
                                JOIN restaurant_master 
                                    ON mds_orders.RestaurantID = restaurant_master.PKID 
     
                            WHERE mds_orders.OrderDate BETWEEN '$date_from' AND '$date_to' 

                             GROUP BY restaurant_master.code, restaurant_master.name"; 

                         
                    $result = mysql_query($sql) 
                              or die("SELECT Error: ".mysql_error()); 
                    $num_rows = mysql_num_rows($result); 
                    echo ' Date select from '.$date_from;
                    echo ' to '.$date_to;
                    echo "<br>";
                    while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){ 
                        //echo $row['name']."<br>"; 
                        $csv .= $row['code'].",". 
                                $row['name'].",". 
                                $row['less100'].",". 
                                $row['less200'].",". 
                                $row['less300'].",". 
                                $row['less400'].",". 
                                $row['less500'].",". 
                                $row['less600'].",". 
                                $row['less700'].",". 
                                $row['less800'].",". 
                                $row['less900'].",". 
                                $row['less1k'].",". 
                                $row['gtr1k'].",". 
                                $row['total'].","."<br>"; 
                             
                        echo $csv;

                //else if(isset($_POST['extract'])){ 
                ?> 
    
            <tr>     
                    <td><?php echo $row['code'];?></td> 
                    <td><?php echo $row['name'];?></td> 
                    <td><?php echo $row['less100'];?></td> 
                    <td><?php echo $row['less200'];?></td> 
                    <td><?php echo $row['less300'];?></td> 
                    <td><?php echo $row['less400'];?></td> 
                    <td><?php echo $row['less500'];?></td> 
                    <td><?php echo $row['less600'];?></td> 
                    <td><?php echo $row['less700'];?></td> 
                    <td><?php echo $row['less800'];?></td> 
                    <td><?php echo $row['less900'];?></td> 
                    <td><?php echo $row['less1k'];?></td> 
                    <td><?php echo $row['gtr1k'];?></td> 
                    <td><?php echo $row['total'];?></td> 
                </tr>
        
        <?php          
                } 
                } 
        ?> 
        </table> 
    </body> 
</html>

and the output of this in a web browser is like this..
Code:
Date select from 2011-10-01 to 2011-11-01
001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
034,GOVERNOR FORBES,,1086,1543,952,399,207,101,52,38,,4402,1412148,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
034,GOVERNOR FORBES,,1086,1543,952,399,207,101,52,38,,4402,1412148,
035,TARLAC ROMULO,,21,45,36,19,7,8,2,1,,141,50897.8,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
034,GOVERNOR FORBES,,1086,1543,952,399,207,101,52,38,,4402,1412148,
035,TARLAC ROMULO,,21,45,36,19,7,8,2,1,,141,50897.8,
037,MARCOS HI-WAY,,331,562,442,238,130,53,28,22,,1816,633708.2,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
034,GOVERNOR FORBES,,1086,1543,952,399,207,101,52,38,,4402,1412148,
035,TARLAC ROMULO,,21,45,36,19,7,8,2,1,,141,50897.8,
037,MARCOS HI-WAY,,331,562,442,238,130,53,28,22,,1816,633708.2,
040,RETIRO,,567,864,564,296,144,86,44,29,,2606,926058,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
034,GOVERNOR FORBES,,1086,1543,952,399,207,101,52,38,,4402,1412148,
035,TARLAC ROMULO,,21,45,36,19,7,8,2,1,,141,50897.8,
037,MARCOS HI-WAY,,331,562,442,238,130,53,28,22,,1816,633708.2,
040,RETIRO,,567,864,564,296,144,86,44,29,,2606,926058,
041,SM MEGAMALL,,48,50,37,26,10,4,4,5,,185,76810,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
034,GOVERNOR FORBES,,1086,1543,952,399,207,101,52,38,,4402,1412148,
035,TARLAC ROMULO,,21,45,36,19,7,8,2,1,,141,50897.8,
037,MARCOS HI-WAY,,331,562,442,238,130,53,28,22,,1816,633708.2,
040,RETIRO,,567,864,564,296,144,86,44,29,,2606,926058,
041,SM MEGAMALL,,48,50,37,26,10,4,4,5,,185,76810,
048,CEBU JONES,,435,526,396,184,99,68,28,29,,1777,664309,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,
014,ALABANG,,657,948,592,361,198,129,86,58,,3064,1172846.8,
018,MCS,,653,777,528,299,171,113,58,56,,2694,1123541.2,
025,LA SALLE TAFT,,1399,1865,983,428,193,90,60,83,,5126,1630377,
026,COMMONWEALTH,,555,920,729,429,212,126,62,43,,3111,1224309.8,
028,LAS PINAS,,638,1101,747,403,184,105,50,35,,3289,1204621,
029,KATIPUNAN,,1459,1631,917,451,238,130,102,69,,5029,1870546.4,
031,ROBINSONS GALLERIA,,74,62,50,12,13,4,8,4,,229,101887,
032,E.RODRIGUEZ,,956,1483,994,498,250,168,85,76,,4552,1714955.4,
034,GOVERNOR FORBES,,1086,1543,952,399,207,101,52,38,,4402,1412148,
035,TARLAC ROMULO,,21,45,36,19,7,8,2,1,,141,50897.8,
037,MARCOS HI-WAY,,331,562,442,238,130,53,28,22,,1816,633708.2,
040,RETIRO,,567,864,564,296,144,86,44,29,,2606,926058,
041,SM MEGAMALL,,48,50,37,26,10,4,4,5,,185,76810,
048,CEBU JONES,,435,526,396,184,99,68,28,29,,1777,664309,
050,DAVAO BAJADA,,213,264,193,117,65,37,20,21,,933,333266,
  	 			001,MORAYTA,,113,154,88,48,24,11,6,9,,458,155606.8,
003,GREENHILLS,,504,777,528,315,166,92,52,59,,2516,1050665.8,
007,UN AVENUE,,518,633,416,235,120,67,42,27,,2080,767881,
008,QUEZON AVENUE,,304,545,362,178,114,53,39,15,,1624,610057.6,
009,GREENBELT,,670,776,569,302,159,109,61,64,,2745,1124906,
010,ROXAS BLVD BACLARAN,,138,225,202,125,65,32,20,21,,836,353104,

there's a lot of duplication..is there anybody can help me how can I remove the duplicates..?


Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 01-24-2012 at 04:50 AM..
# 2  
Old 01-13-2012
Will mysql let you get away with 'SELECT DISTINCT' here?

---------- Post updated at 01:49 PM ---------- Previous update was at 01:44 PM ----------

You could remove a lot of other duplication in your program, too...

Code:
$cols=array('code', 'name', 'less100','less200','less300','less400','less500',
        'less600','less700','less800','less900','less1k','gr1k','total');
$titles=array("Restaurant Code","Restaurant Name","100 & BELOW","101-200",
        "201-300","301-400","401-500","501-600","601-700","701-800",
        "801-900","901-1000","1001 & ABOVE","TOTAL TC ");

...

for($n=0; $n<sizeof($titles); $n++)
        printf("<th>%s</th>\n", $titles[$n]);
...

for($n=0; $n<sizeof($cols); n++) printf("<td>%s</td>\n", $row[$cols[$n]]);


Last edited by Corona688; 01-13-2012 at 04:03 PM..
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 01-24-2012
thank you it helps me a lot.
keep it up. Smilie)

---------- Post updated at 03:51 AM ---------- Previous update was at 03:47 AM ----------
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove duplicate

Hi, How can I replace || with space and then remove duplicate from following text? T111||T222||T444||T222||T555 Thanks in advance (10 Replies)
Discussion started by: tinku981
10 Replies

2. Shell Programming and Scripting

Remove duplicate

Hi , I have a pipe seperated file repo.psv where i need to remove duplicates based on the 1st column only. Can anyone help with a Unix script ? Input: 15277105||Common Stick|ESHR||Common Stock|CYRO AB 15277105||Common Stick|ESHR||Common Stock|CYRO AB 16111278||Common Stick|ESHR||Common... (12 Replies)
Discussion started by: samrat dutta
12 Replies

3. Shell Programming and Scripting

How to remove duplicate ID's?

HI I have file contains 1000'f of duplicate id's with (upper and lower first character) as below i/p: a411532A411532a508661A508661c411532C411532 Requirement: But i need to ignore lowercase id's and need only below id's o/p: A411532 A508661 C411532 (9 Replies)
Discussion started by: buzzme
9 Replies

4. Programming

how to remove duplicate node data by searching tag element

hi everyone, I written one script that search all xml files and create one xml file, but I need to remove some duplicate nodes by testing one tag element. </Datainfo> <data> <test>22</test> <info>sensor value</info> <sensor> <sensor value="23"... (0 Replies)
Discussion started by: veerubiji
0 Replies

5. Shell Programming and Scripting

Delete duplicate data and pertain the latest month data.

Hi I have a file with following records It contains three months of data, some data is duplicated,i need to access the latest data from the duplicate ones. for e.g; i have foll data "200","0","","11722","-63","","","","11722","JUL","09" "200","0","","11722","-63","","","","11722","JUL","09"... (10 Replies)
Discussion started by: vee_789
10 Replies

6. Shell Programming and Scripting

Remove duplicate line detail based on column one data

My input file: AVI.out <detail>named as the RRM .</detail> AVI.out <detail>Contains 1 RRM .</detail> AR0.out <detail>named as the tellurite-resistance.</detail> AWG.out <detail>Contains 2 HTH .</detail> ADV.out <detail>named as the DENR family.</detail> ADV.out ... (10 Replies)
Discussion started by: patrick87
10 Replies

7. Shell Programming and Scripting

remove duplicate

Hi, I am tryung to use shell or perl to remove duplicate characters for example , if I have " I love google" it will become I love ggle" or even "I loveggle" if removing duplicate white space Thanks CC (6 Replies)
Discussion started by: ccp
6 Replies

8. Shell Programming and Scripting

Remove duplicate

Hi all, I have a text file fileA.txt DXRV|02/28/2006 11:36:49.049|SAC||||CDxAcct=2420991350 DXRV|02/28/2006 11:37:06.404|SAC||||CDxAcct=6070970034 DXRV|02/28/2006 11:37:25.740|SAC||||CDxAcct=2420991350 DXRV|02/28/2006 11:38:32.633|SAC||||CDxAcct=6070970034 DXRV|02/28/2006... (2 Replies)
Discussion started by: sabercats
2 Replies

9. Shell Programming and Scripting

Remove duplicate ???

Hi all, I have a out.log file CARR|02/26/2006 10:58:30.107|CDxAcct=1405157051 CARR|02/26/2006 11:11:30.107|CDxAcct=1405157051 CARR|02/26/2006 11:18:30.107|CDxAcct=7659579782 CARR|02/26/2006 11:28:30.107|CDxAcct=9534922327 CARR|02/26/2006 11:38:30.107|CDxAcct=9534922327 CARR|02/26/2006... (3 Replies)
Discussion started by: sabercats
3 Replies

10. Shell Programming and Scripting

remove duplicate

i have a text its contain many record, but its written in one line, i want to remove from that line the duplicate record, not record have fixed width ex: width = 4 inputfile test.txt =abc cdf abc abc cdf fgh fgh abc abc i want the outputfile =abc cdf fgh only those records can any one help... (4 Replies)
Discussion started by: kazanoova2
4 Replies
Login or Register to Ask a Question