Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Sorting and coloring ms sql query output using php
Old 10-16-2008, 05:50 AM Sorting and coloring ms sql query output using php
Junior Talker

Posts: 1
Name: Salvo
Trades: 0
Hi everyone,

As you may understand I'm pretty bad to programming and probably what I'm trying to achieve is something "easy "easy "easy" for you but it's turning out to be a nghtmare for me. I've been researching the web for days and can;t find anything that actually fits my needs and what I found I wasn;t able to make it work.

Basically I'm succesflly retrieving data from a ms sql query using php and now the next steps should be:

1. Make my table sortable by clicking on the title of each column

2. Have the lines in the colum coloroued depending on a condition. For example the difference in hours from the last update (one of the field reitrieved from the quesry) and the current time.

3. Have the page autorefreshing.


I'm stuck at the first step.

Any advice is very welcome.

Here is my code so far:

<?php
$myServer = "one";
$myUser = "two";
$myPass = "three";
$myDB = "heat";
//connection to the database
$connection = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
if (!$connection) {
echo "Couldn't make a connection!";
exit;
}
//select a database to work with
$db = mssql_select_db($myDB, $connection);
// test selection
if (!$db) {
echo "Couldn't select database!";
exit;
}

//declare the SQL statement that will query the database
$sql = "SELECT CallLog.CallID, CallLog.Priority, CallLog.Tracker, CallLog.CallStatus, CallLog.ModDate, CallLog.ModTime, CallLog.EndUserCo
FROM heat.dbo.CallLog CallLog
WHERE CallLog.Tracker='four'
AND CallLog.CallStatus <> 'Closed'";
$sql_result = mssql_query($sql,$connection);
echo "<TABLE BORDER=1>";
echo "<TR>
<TH><font color=##0101DF>Ticket</TH>
<th><font color=##0101DF>Priority</TH>
<th><font color=##0101DF>Status</TH>
<th><font color=##0101DF>LastUpdate</TH>
<th><font color=##0101DF>End Customer</TH>
<th><font color=##0101DF>Owner</th>";
while ($row = mssql_fetch_array($sql_result)) {
$call_id = $row["CallID"];
$priority = $row["Priority"];
$tracker = $row["Tracker"];
$status = $row["CallStatus"];
$modified = $row["ModDate"];
$time = $row["ModTime"];
$customer = $row["EndUserCo"];
echo "<TR><TH>$call_id<TH>$priority<TH>$status<TH>$modi fied<TH>$customer<TH>$tracker";
}
echo "</TABLE>";
mssql_free_result($sql_result);
mssql_close($connection);
?>
waol76 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-16-2008, 03:30 PM Re: Sorting and coloring ms sql query output using php
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
What you need is JavaScript.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Sorting and coloring ms sql query output using php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10191 seconds with 12 queries