All pastes #489928 Raw Edit

sorting columns

public php v1 · immutable
·published 2007-05-15 19:33 UTC
rendered paste body
<?include '../includes/global.php';/*error_reporting(E_ALL);ini_set('display_errors', '1');*/dbconn();loggedinorreturn();if (get_user_class() < UC_ADMINISTRATOR)	stderr("<font color=\"#CC0000\">Error</font>", "Access denied.");stdhead("Administration");$sort=$_GET["sort"];echo 'sort: ' . $sort . '<br/>';$type=($_GET["type"]=="asc"?"asc":"desc");echo 'type: ' . $type . '<br/>';switch($sort){  case 1:$orderby="ORDER BY id ".$type;break;  case 2:$orderby="ORDER BY IA ".$type;break;  case 3:$orderby="ORDER BY claim_no ".$type;break;  case 4:$orderby="ORDER BY date_received ".$type;break;	case 5:$orderby="ORDER BY IVCV ".$type;break;  default:$orderby = "ORDER BY status, date_received";break;}$type=($_GET[type]=="asc"?"desc":"asc");$addparam = "";$addparam.="type=$type";$query = "SELECT * FROM claims WHERE status = 'pending' $orderby";echo 'query: ' . $query . '<br/>';//$res = mysql_query("SELECT * FROM claims WHERE status = 'pending' ORDER BY status, date_received") or sqlerr();$res = mysql_query($query) or sqlerr();$num = mysql_num_rows($res);?><div class="table_wrapper"><h3>PENDING</h3><table>	<tr>	  <th><a href="?sort=1&<?= $addparam; ?>">TS File Number</a></th>	  <th><a href="?sort=2&<?= $addparam; ?>">I/A</a></th>	  <th><a href="?sort=3&<?= $addparam; ?>">Claim Number</a> </th>	  <th><a href="?sort=4&<?= $addparam; ?>">Date Rcvd</a></th>	  <th><a href="?sort=5&<?= $addparam; ?>">IV / CV</a></th>	  <th>Vehicle Owner</th>	  <th>Vehicle Type </th>	  <th>Description </th>	  <th>Status of Assignment </th>	</tr><?for ($i = 0; $i < $num; ++$i){	$arr = mysql_fetch_assoc($res);		$tempDateTime = explode(' ', $arr['date_received']);	$vechicle_type = $arr["vechicle_year"] . ' ' . $arr["vechicle_make"] . ' ' . $arr["vechicle_model"];	list($year, $month, $day) = explode('-', $tempDateTime[0]);?>	<tr>	  <td><a href="viewassignments.php?id=<?= $arr["id"]; ?>">TS<?= $arr["id"]; ?></a></td>	  <td><?= $arr["IA"]; ?></td>	  <td><?= $arr["claim_no"]; ?></td>	  <td><?= $month . '/' . $day . '/' . $year; ?></td>	  <td><?= $arr["IVCV"]; ?></td>	  <td>	  	<?		//Need either cliamant or insured name here depending on IV or CV		$IVCV = $arr["IVCV"];		//echo $IVCV . ' - ';		if ($IVCV == "IV") { echo $arr["insured_name"]; }		elseif ($IVCV == "CV") { echo $arr["claimant_name"]; }		?>	  </td>	  <td><?= $vechicle_type; ?></td>	  <td><?= $arr["description"]; ?></td>	  <td>	  	<?		//Need last note from notes table for this claim		$res2 = mysql_query("SELECT note from notes where claim_id = '" . $arr["id"] . "' ORDER BY note_date DESC LIMIT 0,1 ") or mysql_error();		while ($arr2 = mysql_fetch_assoc($res2)) {			echo $arr2["note"];		}		?>	  </td>	</tr><? } ?></table></div><p>&nbsp;</p><?$res = mysql_query("SELECT * FROM claims WHERE status = 'complete' ORDER BY status, date_received") or sqlerr();$num = mysql_num_rows($res);stdfoot();?>