Jump to content

inneedofhelp

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

inneedofhelp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Great Thanks. I changes things a bit and now want to make the second page sortable. I would like to be able to sort the entrys by the date as a default and by the case number, customer, and date. Here is the code. <?php session_start(); include "reg_vars.php"; include "classes.inc.php"; //Create Sortable Column Links $link1 = "{$_SERVER['PHP_SELF']}?sort=cna";//sort by case number $link2 = "{$_SERVER['PHP_SELF']}?sort=cra";//sort by customer $link3 = "{$_SERVER['PHP_SELF']}?sort=doa";//sort by date //Determine sort order if(isset($_GET['sort'])){ //Use existing sorting order switch ($_GET['sort']){ case 'cna': $order_by = 'Case_No ASC'; $link1 = "{$_SERVER['PHP_SELF']}?sort=csd"; break; case 'cnd': $order_by = 'Case_No DESC'; $link1 = "{$_SERVER['PHP_SELF']}?sort=csa"; break; case 'cra': $order_by = 'Customer ASC'; $link2 = "{$_SERVER['PHP_SELF']}?sort=crd"; break; case 'crd': $order_by = 'Customer DESC'; $link2 = "{$_SERVER['PHP_SELF']}?sort=cra"; break; case 'doa': $order_by = 'Inc_Date ASC'; $link3 = "{$_SERVER['PHP_SELF']}?sort=dod"; break; case 'dod': $order_by = 'Inc_Date DESC'; $link3 = "{$_SERVER['PHP_SELF']}?sort=doa"; break; default: $order_by = 'Inc_Date DESC'; break; } //$sort will be appended to the pagination links. $sort = $_GET['sort']; } else { //Use the default sorting order. $order_by = 'dod'; $sort = 'dod'; } //if (!isset($_SESSION['errcount'])) { $qdb = "test"; $qaction = "select"; $qfieldsarray = array("Case_No", "ErrorCodes", "Inc_Date", "Customer", "Logs"); $qsort = "ErrorCodes"; $active = new QueryClass2($qdb,"active",$qaction,$qfieldsarray,$qconds,$qstartdate,$qenddate,$qsort,$qlim); $resolved = new QueryClass2($qdb,"resolved",$qaction,$qfieldsarray,$qconds,$qstartdate,$qenddate,$qsort,$qlim); $active_data = $active->getData(); $resolved_data = $resolved->getData(); $data = array_merge($active_data, $resolved_data); $c =0; foreach($data as $s){ preg_match_all("/\w{4}/",$s["ErrorCodes"],$codes); if(count($codes[0])>1){ foreach($codes[0] as $co ){ $data[]=array("Case_No"=>$s["Case_No"],"ErrorCodes"=>$co, "Inc_Date"=>$s["Inc_Date"], "Customer"=>$s["Customer"], "Logs"=>$s["Logs"]); } unset($data[$c]); } $c++; } $data = array_values($data); $errcount = array(); foreach( $data as $s ){ $found = false; $c = 0; foreach( $errcount as $r ){ if(strcasecmp($s["ErrorCodes"], $r[1][0]["ErrorCodes"]) == 0 ){ $errcount[$c][1][$r[0]]=$s; $errcount[$c][0]++; $found = true; } $c++; } if( !$found ){ $errcount[count($errcount)]=array(1, array($s)); } } $m = 0; foreach( $errcount as $err){ if($err[0] < 2 ){ unset( $errcount[$m] ); } $m++; } $errcount = array_merge($errcount); $_SESSION['errcount'] = $errcount; //Create Second Page if ($_GET['page'] == "next") { $element = $_GET['element']; $error = $_SESSION['errcount']; $error = $error[$element]; echo '<table border="0" cellpadding="3"> <tr bgcolor=#CCCCCC> <th>Error Code</th> <th><a href="' . $link1 . '">Case Number</a></th> <th><a href="' . $link2 . '">Customer</a></th> <th><a href="' . $link3 . '">Date</a></th> </tr>'; foreach ($error[1] as $e) { if ($i%2 == 0) { $bg = "#EEEEEE"; } else { $bg = "#CCCCCC"; } echo '<tr bgcolor="' . $bg . '"></td> <td>' . $e["ErrorCodes"] .'</td>'; if($e["Logs"]==""){ echo '<td>' . $e["Case_No"] . '</td>'; }else if($e["Logs"]=="Y"){ echo '<td>' . $e["Case_No"] . '</td>'; }else { echo '<td><a href=' . $e["Logs"] . ' target=\"_blank\">' . $e["Case_No"] . '</a></td>'; } echo '<td>' . $e["Customer"] . '</td> <td>' . $e["Inc_Date"] . '</td> </tr>'; $i++; } echo '<table>'; } else { echo '<table border="0" cellpadding="3"> <tr bgcolor=#CCCCCC> <th># Of Events</th> <th>Error Code</th> </tr>'; $i = 0; foreach ($_SESSION['errcount'] as $C) { if ($i%2 == 0) { $bg = "#EEEEEE"; } else { $bg = "#CCCCCC"; } echo ' <tr bgcolor="' . $bg . '"> <td>' . $C[0] . '</td> <td><a href="test.php?page=next&element=' . $i . '">' . $C[1][0]["ErrorCodes"] . '</a></td> </tr>'; $i++; } echo '</table>'; } ?>
  2. Im tring to create the second of two pages. The first page has a table that displays a row number, a count, and an error code. I want the next page to create a table by clicking on the the error code or row number. The table is suppost to diaplay the error code and all case numbers for that code. Here is an array with dummy data. In this array the counts are 3,6,10,12, the error codes are 4,5,6,7, and the case numbers are 31,41,51 for the top row, 32,42,52 for the second row and ect. The code below creates the table on the first page. Please help me create the second page. Thanks $errcount=array(array(3,array(array(31,4),array(41,4),array(51,4))), array(6,array(array(32,5),array(42,5),array(52,5))), array(10,array(array(33,6),array(43,6),array(53,6))), array(13,array(array(34,7),array(44,7),array(54,7)))) <!Set up table headings> <html> <table border="0" cellpadding="3"> <tr bgcolor=#CCCCCC> <th> </th> <th> # Of Events </th> <th> Error Code </th> </tr> <!setup table> <? $i=0;?> <? foreach($errcount as $C){ ?> <tr bgcolor= <?if($i%2 == 0) { echo "#EEEEEE"; } else { echo "#CCCCCC"; }?>> <td> <?echo $i++; ?> </td> <td> <? echo $C[0]; ?> </td> <td> <? echo $C[1][0][1]; ?> </td> </tr> <? } ?> </table> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.