Hello! I'm super stoked I found you guys, this is the quickest, least amount of crap php site I have been able to find and I hope you can help me out. I am running PHP 5.2.4 and connecting to an Access database generated by our phone switch (I would prefer MySql, but the switch software creates and maintains the database, I'm just tapping into it).
I am fairly new to PHP and looking to get some help with a large query I set up for our phone system. Basically, what I want to do, is make the huge hand-coded query more dynamic and smaller so that it returns results faster and I don't have to edit a bunch of code every time something changes (which is often!).
Here is the query:
$sqlCJB = "SELECT Count(*) AS TotalNumberOfCallsCJB FROM AllInfo WHERE Extension = '3911' AND Date=#".$id."#";
$timeCJB = "SELECT Date, Extension, sum(DurationS) AS CountOfDurationCJB
FROM AllInfo
WHERE Extension = '3911'
AND IO = 'Out'
AND Date=#$id#
GROUP BY Date, Extension, IO
";
$queryCJB = odbc_exec($odbc,$sqlCJB) or die(odbc_errormsg());
$timequeryCJB = odbc_exec($odbc,$timeCJB) or die(odbc_errormsg());
/* *** Query Carrie J Boreham*** */
while($row = odbc_fetch_array($queryCJB)) {
echo "<tr>";
echo "<td class=\"borderTable\"><center>3911</center></td class=\"borderTable\">";
echo "<td class=\"borderTable\"><center>Carrie Boreham</center></td class=\"borderTable\">";
echo "<td class=\"borderTable\"><center>".$row['TotalNumberOfCallsCJB']."</center></td class=\"borderTable\">";
while($row = odbc_fetch_array($timequeryCJB)){
echo "<td class=\"borderTable\"><center>".minutestoHours($row["CountOfDurationCJB"])."</center></td class=\"borderTable\">"; }
} // end while
Then I have this in the file 50 times under different query and sql names for all the employees. What I would like to do is figure out how to make this loop on itself based on another file that I can edit on the fly to simple add or remove someone from the list, then have the output sortable by column ( I don't know how to make this sortable. )
echo "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"borderTable\">
<tr><th class=\"borderTable\"> Extension </th><th class=\"borderTable\"> Username </th><th class=\"borderTable\">Total Dials</th><th class=\"borderTable\">Total Talk Time</th></tr>";
Think maybe someone can help me out on this? I know it's probably pretty simple for someone who does this all the time, I just can't figure it out.