Here's the code:
<?PHP
/*
my_orders.php
*/
function my_cp_orders() {
global $content;
global $i_header;
global $queries;
global $yesno;
global $writer_row;
global $WriterId;
//----------------------------------------------------------
$pagelimit = "2";
$strSQL = mysql_query("SELECT ".$queries['orders_fields'].", st.state_id"
." FROM ".ORDERS." o, ".STATES." st"
." WHERE ".$queries['my_cp_orders_states']." AND o.writer_id='".$WriterId."' AND st.state_id=o.state_id"
." ORDER BY st.wr_order, o.writer_deadline DESC") or die(mysql_error());
$totalrows = mysql_num_rows($strSQL);
$pagenums = ceil ($totalrows/$pagelimit);
if ($page==''){
$page='1';
}
$start = ($page-1) * $pagelimit;
//echo "<b>" . $totalrows . " matches found</b><br>\n";
$starting_no = $start + 1;
if ($totalrows - $start < $pagelimit) {
$end_count = $totalrows;
} elseif ($totalrows - $start >= $pagelimit) {
$end_count = $start + $pagelimit;
}
//echo "Results $starting_no to $end_count shown.<br>\n";
if ($totalrows - $end_count > $pagelimit) {
$var2 = $pagelimit;
} elseif ($totalrows - $end_count <= $pagelimit) {
$var2 = $totalrows - $end_count;
}
$space = " ";
//----------------------------------------------------------
$query = "SELECT ".$queries['orders_fields'].", st.state_id"
." FROM ".ORDERS." o, ".STATES." st"
." WHERE ".$queries['my_cp_orders_states']." AND o.writer_id='".$WriterId."' AND st.state_id=o.state_id"
." ORDER BY st.wr_order, o.writer_deadline DESC LIMIT $start,$pagelimit";
$this_content = $i_header;
$this_content .= Menu();
$result = mysql_query($query);
if ( mysql_num_rows($result) ) {
$this_content .= "<table border=\"0\" cellpadding=\"0\"><tr><td>";
$this_content .= "<b>" . $totalrows . " matches found</b><br>\n";
$this_content .= "Results ".$starting_no." to ".$end_count." shown.<br>\n";
if ($page>1) {
$this_content .= "« <a href='" . $PHP_SELF . "?rate=".$_GET['rate']."&page=".($page-1)."' class=main>Previous" . $space . $pagelimit . "</a>" . $space . $space . "";
}
for ($i=1; $i<=$pagenums; $i++) {
if ($i!=$page) {
$this_content .= " <a href='" . $PHP_SELF . "?rate=".$_GET['rate']."&page=$i' class=main>$i</a>";
}
else {
$this_content .= " <b>[".$i."]</b>";
}
}
if ($page<$pagenums) {
$this_content .= "" . $space . $space . $space . $space . " <a href='" . $PHP_SELF . "?rate=".$_GET['rate']."&page=".($page+1)."' class=main>Next " . $var2 . "</a> »";
}
// $this_content .=
$this_content .= "</td></tr></table>";
$this_content .= "<table border=\"0\" cellpadding=\"4\">";
$this_content .= "<thead>";
$this_content .= "<tr bgcolor='#B4B4DA'>";
$this_content .= "<td><a class ='unnamed4'><strong>"."Code"."</strong></a></td>";
$this_content .= "<td><a class ='unnamed4'><strong>"."Topic"."</strong></a></td>";
$this_content .= "<td><a class ='unnamed4'><strong>"."Deadline"."</strong></a></td>";
$this_content .= "<td><a class ='unnamed4'><strong>"."State"."</strong></a></td>";
$this_content .= "<td><a class ='unnamed4'><strong>"."Total"."</strong></a></td>";
$this_content .= "<td><a class ='unnamed4'><strong>"."Salary Paid"."</strong></a></td>";
$this_content .= "<td>".""."</td>";
$this_content .= "</tr>";
$this_content .= "</thead>";
$this_content .= "<tbody>";
$i=0;
while ($row = mysql_fetch_assoc($result)) {
if ( intval($i/2) + (1/2) > ($i/2) ) {
$this_content .= "<tr bgcolor='#ffffff'>";
} else {
$this_content .= "<tr bgcolor='#EAF2F9'>";
}
$i++;
//$this_content .= "<tr>";
$query3 = "SELECT * FROM ".FEEDBACKS." f WHERE f.order_id='".$row['order_id']."' AND f.valid='1'";
$result3 = mysql_query( $query3 );
$fstr = "";
if (($result3) && ( $n = mysql_num_rows( $result3 ) )) {
$fstr = "<br><a class=\"small2\" href=\"?rate=3&id=".$row['order_id']."\">Feedbacks: ".$n."</a>";
}
$s = get_feedbacksbyorder_numstr(1, $row['order_id']);
if ($s != "") { $s = "<br>".$s; }
$this_content .= "<td><a class ='unnamed4'>".$row['code']."</a></td>";
$this_content .= "<td><a class ='unnamed4'>".$row['topic']."</a><br>".get_instructions_numstr($row['order_id'])."<br>".get_notes_numstr($row['order_id'], $WriterId)."</td>";
$this_content .= "<td><a class ='unnamed4'>".date("F j Y G:i", strtotime($row['writer_deadline'])+60*60*($writer_row['wr_timezone']-2))."</a></td>";
$this_content .= "<td><a class ='unnamed4'>".get_wr_statename($row['state_id'])."</a>".$fstr."".$s."</td>";
$this_content .= "<td><a class ='unnamed4'>".$row['total']."</a></td>";
$this_content .= "<td><a class ='unnamed4'>".getOrderWrPaymentsNumStr($row['order_id'])."</a></td>";
$this_content .= "<td>"."<a class = 'small' href=?rate=20&order=".$row['order_id'].">Detail and Upload</a>"."</td>";
$this_content .= "</tr>";
}
$this_content .= "</tbody>";
$this_content .= "</table>";
} else {
$this_content .= "<br>No orders yet";
}
CloseTable();
$this_content .= "</body></html>";
$content .= $this_content;
}
?>
Thanks a lot for any help...