1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Rep Power


    above is my table in db

    PHP Code:
    /*foreach ($_POST as $a=>$b){
            echo $a.":".$b."<br/>";
    $from     $_POST["from"];
    $to     $_POST["to"] ;
    $sel     $_POST["select"];
    $dur    $_POST["dur"];
    $sql "
                SELECT billsec, clid , src , lastapp , duration,disposition,SUM(billsec),COUNT(billsec)
                FROM cdr
                WHERE   calldate > '
                    AND calldate < '
                    AND duration > '
                    AND src = '
                    AND lastapp     != 'busy'
                    AND disposition !='FAILED'
                    AND disposition !='NO ANSWER'
                    AND disposition !='BUSY'
    $result mysql_query($sql);

    if (
    mysql_num_rows($result) == 0) {
    "No rows found, nothing to print so am exiting";

    <table  class="tablo1" border="1">
            <td><div>No :             </div></td>
            <td><div>src :         </div></td>
            <td><div>lastapp :         </div></td>
            <td><div>Type :         </div></td>
            <td><div><?php echo $dur ?>sn U.T.A</div></td>
            <td><div><?php echo $dur ?>sn U.T.S</div></td>


    while (
    $row mysql_fetch_array($result)) {   
    .$i                        .' </div></td>
    .$row["clid"]                .'</div></td>
    .$row["src"]                .'</div></td>
    .$row["lastapp"]            .'</div></td>
    .$row["COUNT(billsec)"]    .'</div></td>
    .$row["SUM(billsec)"]        .'</div></td>


    i wanna list some values' COUNTand SUM in a table at the same time when lastapp changed bu i cant for example

    when lasapp is dial and src = 110 and all billsec SUM and COUNT
    lastapp is hungup and src = 110 and all billsec SUM and COUNT
    lastapp is wait and src = 110 and all billsec SUM and COUNT
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Rep Power

    first of all, you need to fix several security holes:

    Donít insert raw values into query strings.
    Donít output raw values or insert them into the HTML page.

    After 7 years, I think it might be a good idea to start writing secure and correct code.

    Your query description I don't really understand. How exactly is your output supposed to look like?

    The current query is neither valid nor sensible. MySQL will swallow it, anyway, but on other database systems, this wouldn't even run. You cannot have aggregate functions (SUM, COUNT) and normal columns intermixed (unless they appear in the GROUP BY clause).

    Actually, this is a pure MySQL question, so wait for a moderator to move it.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo