Advertisement

09.22.2008 at 01:27PM PDT, ID: 23752855
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.7

Output not Sorting Correctly

Asked by TTCLIVE in SQL Query Syntax, PHP and Databases

Tags: , ,

I have this query that sorts through an Access database and pulls out a list of all the calls that took place on a specific extension. The query works for pulling all the calls, then when it displays them on the page, they are not always in order.

I would like to be able to simply click the column header and have the whole table resort itself based on the header like in Excel.

If that's not possible, maybe just having everything sort by Date correctly would work fine.

Any body want to take a stab at it for me?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
<html><head>
 
<link href="style.css" rel="stylesheet" type="text/css">
<link href="Scripts/EnterSubmit.js" rel="javascript" type="text/javascript">
<script type="text/javascript" src="ddtabmenufiles/ddtabmenu.js">
 
/***********************************************
* DD Tab Menu script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//DD Tab Menu- Last updated April 27th, 07: http://www.dynamicdrive.com
//Only 1 configuration variable below
 
var ddtabmenu={
	disabletablinks: false, ////Disable hyperlinks in 1st level tabs with sub contents (true or false)?
	currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/)
 
definemenu:function(tabid, dselected){
	this[tabid+"-menuitems"]=null
	this.addEvent(window, function(){ddtabmenu.init(tabid, dselected)}, "load")
},
 
showsubmenu:function(tabid, targetitem){
	var menuitems=this[tabid+"-menuitems"]
 for (i=0; i<menuitems.length; i++){
		menuitems[i].className=""
		if (typeof menuitems[i].hasSubContent!="undefined")
			document.getElementById(menuitems[i].getAttribute("rel")).style.display="none"
	}
	targetitem.className="current"
	if (typeof targetitem.hasSubContent!="undefined")
		document.getElementById(targetitem.getAttribute("rel")).style.display="block"
},
 
isSelected:function(menuurl){
	var menuurl=menuurl.replace("http://"+menuurl.hostname, "").replace(/^\//, "")
	return (ddtabmenu.currentpageurl==menuurl)
},
 
addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},
 
init:function(tabid, dselected){
	var menuitems=document.getElementById(tabid).getElementsByTagName("a")
	this[tabid+"-menuitems"]=menuitems
	for (var x=0; x<menuitems.length; x++){
		if (menuitems[x].getAttribute("rel")){
			this[tabid+"-menuitems"][x].hasSubContent=true
			if (ddtabmenu.disabletablinks)
				menuitems[x].onclick=function(){return false}
		}
		else //for items without a submenu, add onMouseout effect
			menuitems[x].onmouseout=function(){this.className=""}
		menuitems[x].onmouseover=function(){ddtabmenu.showsubmenu(tabid, this)}
		if (dselected=="auto" && typeof setalready=="undefined" && this.isSelected(menuitems[x].href)){
			ddtabmenu.showsubmenu(tabid, menuitems[x])
			var setalready=true
		}
		else if (parseInt(dselected)==x)
			ddtabmenu.showsubmenu(tabid, menuitems[x])
	}
}
}
 
//SYNTAX: ddtabmenu.definemenu("tab_menu_id", integer OR "auto")
ddtabmenu.definemenu("ddtabs1", 0) //initialize Tab Menu with ID "ddtabs1" and select 1st tab by default
</script>
<style type="text/css">
<!--
.style2 {
	font-size: 16px;
	font-style: italic;
	color: #00FF00;
}
-->
</style>
 
<body>
 
<div id="ddtabs1" class="basictab">
<ul>
<li><a href="DailyCallTotals_SelectDate.php" rel="sc2">Calls By Team</a></li>
<li><a href="CallsByHour.php" rel="sc2">Calls By Hour</a></li>
<li class="style2"><a href="AllCalls.php" rel="sc1">All Calls By Extension</a></li>
 
</ul>
</div>
 
<h2>Show All Calls by Extension</h2>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
  <div align="left">Enter Date: 
    <input type="text" name="id" value="<?php echo date("m/d/y");?>">
    <br>
    Enter Ext:&nbsp;&nbsp;
    <input type="text" name="ex" value="">
    <br>
    <input type="submit" name="submit" value="Submit" onKeyPress="return submitenter(this,event)">
  </div>
</form>
<?php 
//require_once('odbc.php'); 
//
//$query = odbc_exec($odbc, "SELECT Top 1 * FROM AllInfo WHERE IO = 'Out' AND CO = '54' ORDER BY [DateTime] DESC, [Extension] DESC") or die (odbc_errormsg()); 
//while($row = odbc_fetch_array($query)) 
//{ 
//    echo 'Database current as of<strong> '.date("F j, Y, g:i a", strtotime($row['DateTime'])).'</strong> and will update every 23 minutes.'; 
//} 
//odbc_close($odbc); 
//?> 
<hr>
 
<p><?php
require_once('odbc.php');
 
// Transform minutes like "105" into hours like "1:45". 
  function minutesToHours ($sec, $padHours = false)
  {
 
    // holds formatted string
    $hms = "";
    
    // there are 3600 seconds in an hour, so if we
    // divide total seconds by 3600 and throw away
    // the remainder, we've got the number of hours
    $hours = intval(intval($sec) / 3600); 
 
    // add to $hms, with a leading 0 if asked for
    $hms .= ($padHours) 
          ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':'
          : $hours. ':';
     
    // dividing the total seconds by 60 will give us
    // the number of minutes, but we're interested in 
    // minutes past the hour: to get that, we need to 
    // divide by 60 again and keep the remainder
    $minutes = intval(($sec / 60) % 60); 
 
    // then add to $hms (with a leading 0 if needed)
    $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
 
    // seconds are simple - just divide the total
    // seconds by 60 and keep the remainder
    $seconds = intval($sec % 60); 
 
    // add to $hms, again with a leading 0 if needed
    $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
 
    // done!
    return $hms;
    
  }
 
if(isset($_POST['submit'])) {
 
      $id = $_POST['id'];
      $ex = $_POST['ex'];
     
      if($id!="" & $ex!="") {
 
echo "<b>Total number of calls for : ".$id."<br></b>";
  $unixtime = time();
  echo "" . date("F j, Y, g:i a",$unixtime) . "<br><br>";
 
          $sql = "SELECT Count(*) AS TotalNumberOfCalls FROM AllInfo WHERE Extension = '$ex' AND Date=#".$id."#";
				$time = "SELECT Date, Extension, sum(DurationS) AS CountOfDuration 
					FROM AllInfo 
					WHERE Extension = '$ex' AND Date=#$id#				
					GROUP BY Date, Extension";
          $sql0 = "SELECT * FROM AllInfo WHERE Extension = '$ex' AND Date=#$id#";
					
            $sql = odbc_exec($odbc,$sql) or die(odbc_errormsg());   
				$timequery = odbc_exec($odbc,$time) or die(odbc_errormsg());
             $sql0 = odbc_exec($odbc,$sql0) or die(odbc_errormsg());   
 
            echo "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"borderTable\"><tr><th class=\"borderTable\">   Extension   </th><th class=\"borderTable\">     Time     </th><th class=\"borderTable\">Total Dials</th><th class=\"borderTable\">Total Talk Time</th></tr>";
			
			            while($row = odbc_fetch_array($sql)) {
               
			      echo "<tr>";
                  echo "<td class=\"borderTable\"><center>$ex</center></td class=\"borderTable\">";
                  echo "<td class=\"borderTable\"><center>00:01-23:59</center></td class=\"borderTable\">"; 
                  echo "<td class=\"borderTable\"><center>".$row['TotalNumberOfCalls']."</center></td class=\"borderTable\">";
 
				  		while($row = odbc_fetch_array($timequery)){
						
				  echo "<td class=\"borderTable\"><center>".minutesToHours($row["CountOfDuration"])."</center></td class=\"borderTable\"></table><p></p>";	}
            } // end while
			
            echo "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"borderTable\"><tr><th class=\"borderTable\">   Extension   </th><th class=\"borderTable\">     Time     </th><th class=\"borderTable\">In/Out</th><th class=\"borderTable\">Phone Number</th><th class=\"borderTable\">Duration</th></tr>";
 
				while($row = odbc_fetch_array($sql0)) 
				{ 
			      echo "<tr>";
					echo '<td class=\"borderTable\"><center>'.$row['Extension'].'</center></td class=\"borderTable\">'; 
					echo '<td><center>'.date("h:i", strtotime($row['DateTime'])).'</center></td>';  
					echo '<td class=\"borderTable\"><center>'.$row['IO'].'</center></td class=\"borderTable\">';
					echo '<td class=\"borderTable\"><center>('.$row['AC'].') ';
					echo ''.$row['PhN'].'</center></td class=\"borderTable\">';
					echo '<td class=\"borderTable\"><center>'.$row['Duration'].'</center></td class=\"borderTable\">';
 
            } // end while
			
      } // end if
     
} // end if
?>
 
  <?php
odbc_close($odbc);
 
?>
</p>
<p>  
</p>
</body></html>
[+][-]09.22.2008 at 02:11PM PDT, ID: 22544184

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 02:39PM PDT, ID: 22544445

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 02:58PM PDT, ID: 22544611

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 03:10PM PDT, ID: 22544720

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 03:24PM PDT, ID: 22544848

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 03:28PM PDT, ID: 22544880

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, PHP and Databases
Tags: Microsoft, Access, SQL query through PHP
Sign Up Now!
Solution Provided By: mwvisa1
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.22.2008 at 03:33PM PDT, ID: 22544917

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 03:46PM PDT, ID: 22544981

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 03:51PM PDT, ID: 22545013

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.22.2008 at 04:04PM PDT, ID: 22545108

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628