Hellow everyone,
Sorry I can't give a title to my request. This is a file that print a list of links in the database. There is 2 fields I ofter use; memberID and recipURL. Sometimes I need to see the list by URL, ASC or DESC, and sometimes by memberID, also ASC or DESC.
I want to make this file to print the list either by memberID or recipURL, either ASC or DESC. I have saw before this, but I don't know php too much.
If anyone can give details how I can implement this, I will really appreciate.

thanks
greg

Code:
<?
session_start();
//////////////////////////Authenticate///////////////////////////////////////////////////////////////////
if (!isset($loginset)){
header("Location: login.php");
}
 require('global.php');

$result = mysql_query(" SELECT * FROM site_info ");

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $ownerName = $row["ownerName"];
			$siteName = $row["siteName"];
			$siteURL  = $row["siteURL"];
			$homeDirectory  = $row["homeDirectory"];
			$appDirectory = $row["appDirectory"];
			$appURL = $row["appURL"];
			$siteDescription  = $row["siteDescription"];
			$email = $row["email"];
			$sortType  = $row["sortType"];
			$approvalType  = $row["approvalType"];
			$staticType  = $row["staticType"];
			$listingsAmount  = $row["listingsAmount"];
			$metaKeywords  = $row["metaKeywords"];
			$metaDescription  = $row["metaDescription"];

}
if ($sortType == "alphabetical"){
$sortorder = "ORDER BY `memberTitle` ASC";
}
if ($sortType == "sort"){
$sortorder = "ORDER BY `sort`";
}
if ($sortType == "submission"){
$sortorder = "ORDER BY `memberID` DESC";
}
// $linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y'");
// $num_links = mysql_num_rows($linkCount);

$styles = mysql_query("SELECT * FROM styles");
while ($row = mysql_fetch_array($styles, MYSQL_ASSOC)) {
$mainWidth  = $row["mainWidth"];
$bgColor  = $row["bgColor"];
}
////////////////////////////////////////////////////////////////////////////////////////////
$catCount = mysql_query("SELECT * FROM categories ORDER BY `cat_name` ");
$num_cat = mysql_num_rows($catCount);
$catAmount  = $num_cat;

$linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y' ORDER BY `recipURL` DESC LIMIT 0 , 50 ");
$num_links = mysql_num_rows($linkCount);
$linkAmount  = $num_links;

// $linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y' ORDER BY `memberID` DESC LIMIT 0 , 50 ");
///////////////////////////////////////////////////////////
$authquery = mysql_query("SELECT * FROM admin_info");
while ($row = mysql_fetch_array($authquery)){
$usedlogin = $row['adminLogin'];
$usedpassword = $row['adminPass'];
}
if (($usedlogin != $Login) && ($usedpassword != $Pass)){
header("Location: login.php");
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// include("../inc/maincommon.php");
//////////////////////////////////////////////////////////////////////


$catCount = mysql_query("SELECT * FROM categories");
$num_cat = mysql_num_rows($catCount);
$catAmount  = $num_cat;

$linkCount = mysql_query("SELECT * FROM member_info");
$num_links = mysql_num_rows($linkCount);
$linkAmount  = $num_links;

//////////////////////////////////Set nav/////////////////////////////////////////
if (!isset($page)){
$page = 1;
}
$total = $num_links;  
$limit = 50;  
$page = $page;
$numPages = ceil($total / $limit);  
$offset = ($page - 1) * $limit;
$linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y' ORDER BY `recipURL` ASC limit $offset, $limit ");

if($page < $numPages){
$nomorepages = "NEXT";
}
/////////////////////////////////////////////////////////////////

if ($mode == "activate"){
activateuser();
}
if ($mode == "delete"){
deleteuser();
}

/* ================================================================
  BEGINNING OF FUNTION NOTIFY  */

if ($mode == "notify"){
notifyuser();
}

function notifyuser(){
$user = $_GET['user'];
$sql = "UPDATE member_info SET verifiedURL = 'Y' WHERE memberID = '$user'";
if ( @mysql_query($sql) ) {
  echo("<center><font face=arial color=\"red\">E-mail sent to user</font></center>");
} else {
  echo("<p>Error performing update: " . mysql_error() . "</p>");
}

include("../inc/maincommon.php");

////////////////send the email

$emailnotify = mysql_query("SELECT * FROM member_info WHERE memberID = '$user' ");
while ($row = mysql_fetch_array($emailnotify, MYSQL_ASSOC)) {
$memberEmail = $row['memberEmail'];
$memberName = $row['memberName'];
$memberLogin = $row['memberLogin'];
$memberPass = $row['memberPass'];
$memberURL = $row['memberURL'];
$memberTitle = $row['memberTitle'];
$memberDescription = $row['memberDescription'];
$recipURL = $row['recipURL'];
$verifiedURL = $row['verifiedURL'];
$signupDate = $row["signupDate"];
$correctformat=date('M d, Y' ,strtotime($row["signupDate"]));
}
$message = "
RECIPROCAL LINK NOT FOUND!
-----------------------------------------------------

On $correctformat you placed your listing at $siteURL but we cannot find your reciprocal link-back to us located at $recipURL which is a requirement for your listing to be posted on our link directory.

If you have moved our listing and would like to update the information you posted simply reply this email with the new location so we can update your listing.

Our system checks for reciprocal link-backs every 24 hours and your listing can be suspended until our link is found.

Thank you for your reciprocal link we hope to keep our link partnership with you,

$ownerName
$siteName
$siteURL
";

mail ( "$memberEmail", "Reciprocal Link Not Found", $message, "From: $email" );
echo "<font face=Verdana color=red size=1 > Sent email to: </font><font face=Verdana color=black size=1>".$memberEmail."</font><br>";
}
/* ================================================================
  END OF FUNTION NOTIFY  */

//$ip = getenv("REMOTE_ADDR");
//$sqldate = date(Ymd);
//$cleandate = date("l dS of F Y h:i:s A");

include("inc/header-inc.php");

?>
<link href="inc/adminstyle.php" rel="stylesheet" type="text/css">

<table width="800"" border="0" align="center" cellpadding="0" cellspacing="3">
<tr>
<td>
<span class="categoryHeader"><font face="Arial, Helvetica, sans-serif"><strong>Administration</strong></font></span></td>
</tr>
</table>


<table width="800"" border="0" align="center" cellpadding="0" cellspacing="1" class="solidbox">
<tr>
<td>
<table width="100%" border="0" cellpadding="8" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="boxes">
<tr>
<td>Menu:</td>
</tr>
</table>
<?
include("menu.php");
?>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="dottedbottom">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<br>
</td>
<td width="75%" valign="top"><span class="maintext">
            <p class="categoryHeader"><strong><font size="3">All Suspended (50 per page)</font></strong></p>
<hr size="1" class="dottedline">
</span>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="smallboxes">
<tr>
<td>Site Name</td>
</tr>
</table>
</td>
<td width="120">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="smallboxes">
<tr>
<td>
<div align="center">Status</div>
</td>
</tr>
</table>
</td>
<td width="130">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="smallboxes">
<tr>
<td>
<div align="center">Options</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<hr size=1 class="dottedline">
<?
/////////////////////find listings ///////////////////////////////////////////////////////
$sitelink = $siteURL;
while ($links = mysql_fetch_array($linkCount, MYSQL_ASSOC)) {
$memberTitle = $links["memberTitle"];
$memberLink = $links["memberURL"];
$memberID = $links["memberID"];
$recipURL = $links["recipURL"];
$signupDate = $links["signupDate"];
////////////////////Check for reciprocal/////////////////////////////////////////////////

/*
$findlink = @ implode('', file($recipURL));
if ($findlink) {
if (eregi("$sitelink", $findlink)) {
$verifyimage = "<img align=\"center\" src=".$appURL."/images/found.gif>";
} else {
$verifyimage = "<img align=\"center\" src=".$appURL."/images/norecip.gif>";
}
} else {
$verifyimage = "<img align=\"center\" src=".$appURL."/images/nosite.gif>";
}
*/

/////////////////////////////////////////////////////////////////////////////////////////////
echo "<table class=\"smalltext\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">
<tr>
<td width=\"100%\" align=\"left\" font size=1> <a href=\"".$recipURL."\" target=\"_blank\"><font size=1>".$recipURL."</font></a></td>
</tr>
<tr>

<td align=\"right\" width=\"103%\"><font size=\"1\">
<a href=\"edit_user_listing.php?user=".$memberID."\" \"target=\"_blank\"><img src=\"".$appURL."/images/edit.gif\" border=0></a>  	
<a href=\"?mode=activate&user=".$memberID."\" \"target=\"_blank\">ACTIVATE</a> 
<a href=\"?mode=delete&user=".$memberID."\" \"target=\"_blank\">DELETE</a>  
<a href=\"?mode=notify&user=".$memberID."\" \"target=\"_blank\">NOTIFY SUSP</a> </font></td>
</tr></table>
<hr size=1 class=\"dottedline\">";
}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="smallboxes">
<tr>
<td>
<div align="center">&nbsp;</div>
</td>
</tr>
</table>
</td>
<td width="150">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="smallboxes">
<tr>
<td>

<div align="center"><img src="<? echo $appURL; ?>/images/previous.gif" width="6" height="6" hspace="5"><a href="<? echo $PHP_SELF; ?>?page=<? echo $page - 1; ?>"><? if ($page > 1){ echo "PREVIOUS | "; } ?></a><a href="<? echo $PHP_SELF; ?>?page=<? echo $page + 1; ?>"><? echo $nomorepages; ?></a><img src="<? echo $appURL; ?>/images/listingsq.gif" width="6" height="6" hspace="5">&nbsp;</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div align="center" class="tinytext">
<p><font size="1"><img src="<? echo $appURL; ?>/images/found.gif" width="13" height="12">= Reciprocal Found&nbsp;&nbsp; <img src="<? echo $appURL; ?>/images/norecip.gif" width="13" height="10">= No Reciprocal&nbsp;&nbsp; <img src="<? echo $appURL; ?>/images/nosite.gif" width="20" height="10"> = Web Page Not Found</font></p>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div align="center">
<table width="800"" border="0" align="center" cellpadding="0" cellspacing="1" class="boxes">
<tr>
<td><div align="right">&nbsp;<a href="index.php"><strong><font size="1">Home</font></strong></a> &nbsp; </div></td>
</tr>
</table>
<br>
</div>
<?
function activateuser(){
$user = $_GET['user'];
$sql = "UPDATE member_info SET verifiedURL = 'Y' WHERE memberID = '$user'";
if ( @mysql_query($sql) ) {
  echo("<center><font face=arial color=\"red\">Listing has been ACTIVATED!</font></center>");
} else {
  echo("<p>Error performing update: " . mysql_error() . "</p>");
}

include("../inc/maincommon.php");

////////////////send the email//////////////////////////////////////////////////

$emailuser = mysql_query("SELECT * FROM member_info WHERE memberID = '$user' ");
while ($row = mysql_fetch_array($emailuser, MYSQL_ASSOC)) {
$memberEmail = $row['memberEmail'];
$memberName = $row['memberName'];
$memberLogin = $row['memberLogin'];
$memberPass = $row['memberPass'];
$memberURL = $row['memberURL'];
$memberTitle = $row['memberTitle'];
$memberDescription = $row['memberDescription'];
$recipURL = $row['recipURL'];
$verifiedURL = $row['verifiedURL'];
}
$message = "
YOUR LISTING HAS BEEN ACTIVATED!
-----------------------------------------------------
$cleandate

Name: $memberName

URL: $memberURL

Title: $memberTitle

Description: $memberDescription

Reciprocal: $recipURL

Login to your admin panel to modify your listing:
$appURL/login.php

Member Login: $memberLogin
Member Password: $memberPass

";

mail ( "$memberEmail", "Your listing has been activated!", $message, "From: $email" );
echo "<font face=Verdana color=red size=1 > Sent email to: </font><font face=Verdana color=black size=1>".$memberEmail."</font><br>";

//////////////////////////end activate user///////////////////////////////////////////

}

///////////////////////////////end suspenduser///////////////////////////////////

function deleteuser(){
$user = $_GET['user'];
$sql = "DELETE FROM member_info WHERE memberID = '$user'";
if ( @mysql_query($sql) ) {
  echo("<center><font face=arial color=\"red\">Listing has been DELETED!</font></center>");
} else {
  echo("<p>Error performing update: " . mysql_error() . "</p>");
}
/////////////////////////end delete user/////////////////////////////////////////

}
?>
<?
include("inc/footer-inc.php");
?>