edwardoit Posted February 28, 2008 Share Posted February 28, 2008 guys help. i have my while ($list = mysql_fetch_assoc($result)) { ###my result table here } i have generated a fine result. inside the while(), and i have set some conditions on one of the column in orer to meet my need, it works fine. like: $zero = $overlap > 0 ? $overlap : '0'; now i want to list $overlap greater than zero., can anybody teach me what should i do?? * i want the list below my result table. thanks in advance... Quote Link to comment Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 Your best doing this in your query, can we see it? Quote Link to comment Share on other sites More sharing options...
edwardoit Posted February 28, 2008 Author Share Posted February 28, 2008 it's so shameful how i constructed my php script. but i really need to solve my prob. Here's some... my sql: $query = "SELECT concat(left(date_wr,2),date_call) as datecall, time_call, inroute,outroute,caller,called, duration, left(date_wr,2) as year from cdr_test_dump where date_call >= '$start_date' and date_call <= '$end_date' and ($param) order by date_call,time_call "; <table class="prod" align="center"> <tr align="center" class="title"><td>Date Call</td><td>Time Call</td><td>Time Call<br />(Hour)</td><td>Inroute</td><td>Caller</td><td>Outroute</td><td>Called</td><td>Sec Dur</td><td>Min Dur</td><td>Recomp</td><td>T/F</td><td>Billable <br/>Min</td><td>Billable <br/>Peso</td><td>Overlap<br />Check</td></tr> <? while ($search = mysql_fetch_assoc($result)) { $year = substr($search['date_wr'],0,2); $bg = $i % 2 == 0 ? 'FFF' : 'F5F5F5'; $time2 = $time_arr[$i] = $myresult[$i-1]["time_call"]; $time1 = $search['time_call']; $bg = $i % 2 == 0 ? 'FFF' : 'F5F5F5'; $timeinit = $search['time_call']; $hour = substr($timeinit, 0, 2); $min = substr($timeinit,2,2); $sec = substr($timeinit,4,2); $time = $hour.':'.$min.':'.$sec; $timeofcall = strtotime($time); $initial_time = date('H:i:s', $timeofcall); $minutes = number_format($search['duration'],2, '.', '') / 60; $rduration=round($minutes,2); $timelap = $time2; $hour2 = substr($timelap, 0, 2); $min2 = substr($timelap,2,2); $sec2 = substr($timelap,4,2); $time2 = $hour2.':'.$min2.':'.$sec2; $timeofcall2 = strtotime($time2); $lap_time = date('H:i:s', $timeofcall2); $time_diff = date("H:i:s",(strtotime($lap_time) - strtotime($initial_time))); $sec_diff = date("s",(strtotime($lap_time) - strtotime($initial_time))); $min_diff = date("i",(strtotime($lap_time) - strtotime($initial_time))); $hour_diff = date("H",(strtotime($lap_time) - strtotime($initial_time))); $xtime = $hour_diff.':'.$min_diff.':'.$sec_diff; $strsec = (int)$sec_diff; $strmin = (int)$min_diff * 60; $strhour = (int)$hour_diff * 360; $time_diff = round((number_format(($strhour + $strmin + $strsec),2, '.', '') / 60),2); $color = $rduration > $time_diff ? 'BFDC09' : $bg; $overlap = $rduration - $time_diff; $zero = $overlap > 0 ? $overlap : '<font color="#688A5F"> /</font>'; $zero_color = $overlap > 0 ? 'F00' : '000'; $sec_dur = $search['duration'] * 1; $recomp = $search['duration'] <= 6 ? '0' : $search['duration']/60; $recomp = round($recomp,2); $bill_min = $recomp == $rduration ? $recomp : 0; $tf = $recomp == $rduration ? 'TRUE' : 'FALSE'; $peso = $bill_min * $cfg['dollar_rate'] * .18; $peso = number_format($peso,2); $total_overlap = $zero = $zero; $ttotal_overlap += $total_overlap; echo "<tr style=\"background: #$bg\"><td style=\"text-align: center;\">"; echo fnGetDate($search['datecall']); echo "</td><td style=\"text-align: center;\">$initial_time</td>"; echo "</td><td style=\"text-align: center;\">$hour</td>"; echo "<td style=\"text-align: center;\">{$search['inroute']}</td>"; echo "<td style=\"text-align: center;\">{$search['caller']}</td>"; echo "<td style=\"text-align: center;\">{$search['outroute']}</td>"; echo "<td style=\"text-align: center;\">{$search['called']}</td>"; echo "<td style=\"text-align: center;\">$sec_dur</td>"; echo "<td style=\"text-align: left;\">$rduration</td>"; echo "<td style=\"text-align: center;\">$recomp</td>"; echo "<td style=\"text-align: center;\">$tf</td>"; echo "<td style=\"text-align: right;\">$bill_min</td>"; echo "<td style=\"text-align: right;\">$peso</td>"; echo "<td style=\"text-align: center;background-color:#$color;\">$zero</td></tr>"; $i++; } $total = number_format($total,''); $ttotal_overlap = number_format($ttotal_overlap,2); echo "<tr><td colspan = \"14\"><hr></td></tr>"; echo "<tr><td style=\"text-align: left;\">Total Records:</td>"; echo "<td style=\"text-align: left;\"><h2 style=\"border: 1px; border-bottom: 1px double; border-top-style: ridge;\">$total</h2></td><td colspan = \"11\" align=\"right\">Total Overlap Minutes</td><td align=\"center\"><h2 style=\"border: 1px; border-bottom: 1px double; border-top-style: ridge;\">$ttotal_overlap</h2></td>"; echo "</tr>"; i want to display the list summary of overlaps below this last <tr></tr>... i can display the total overlaps with $ttotal_overlap. i just don't know how to populate the overlaps to show the summary. apologies with my code. noob here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.