SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: How to do this? - sorry
-
Jan 14, 2005, 18:57 #1
- Join Date
- Jun 2004
- Location
- Florida
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to do this? - sorry
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> </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"> </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"> </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 <img src="<? echo $appURL; ?>/images/norecip.gif" width="13" height="10">= No Reciprocal <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"> <a href="index.php"><strong><font size="1">Home</font></strong></a> </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"); ?>
-
Jan 14, 2005, 23:29 #2
- Join Date
- Jan 2005
- Location
- California
- Posts
- 28
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
if you narrowed it down a bit i'd be willing to take a look. what do you have for the MySQL query so far?
-
Jan 14, 2005, 23:50 #3
- Join Date
- Jun 2004
- Location
- Florida
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thank you SmoothDime
Ok, I have this query to get all data from the table member_info:
$linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y' ORDER BY `memberID` ASC limit $offset, $limit ");
As you see there, it is sorted by memberID, ASC, but sometimes I need this DESC, and sometimes I need this not sorted by memberID but by recipURL, which is another value in the table, (column)
Now, I want to make a form to GET the list of members either by memberID or recipURL, ASC or DESC, according to my needs. I have saw before some pages we can select how we want to display a list, by product name, by price, etc, and the order.
I think it is something like:
<form action='------- ' method='GET'
<option value='i' {SORT_ID}>memberID</option>
<option value='n' {SORT_NAME}>recipURL</option>
<option value='ASC' {SORT_ASC}>ASC</option>
<option value='DESC' {SORT_DESC}>DES</option>, etc, etc.
But not sure if a function must be created, and how.
I really appreciate your help.
greg
-
Jan 15, 2005, 17:09 #4
- Join Date
- Jun 2004
- Location
- Florida
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hello,
someone can give me some ideas how to do this PLEASE, PLEASE!
thank you!
greg
-
Jan 15, 2005, 17:19 #5
- Join Date
- Nov 2004
- Location
- Parry Sound, ON
- Posts
- 725
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
$order = $_GET['order']?$_GET['order']:'ASC';
$sortfield = $_GET['sortfield']?$_GET['sortfield']:'memberID';
$linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y' ORDER BY $sortfield $order LIMIT $offset, $limit ");
-
Jan 15, 2005, 18:51 #6
- Join Date
- Jun 2004
- Location
- Florida
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hello HardCoded,
thank you for your help!
I have changed the first part of your code to include the second field, and the DESC order (not sure if this is the correct way)
$order = $_GET['order']?$_GET['order']:'ASC' || 'DESC';
$sortfield = $_GET['sortfield']?$_GET['sortfield']:'memberID' || 'recipURL';
Also, I have created the form:
Code:<form action='list.php' method='GET'> <td> <table cellpadding="1" cellspacing="0" border="0"> <tr> <td class="smallText" style="padding:2px;"> Sort By: <td class="smallText" style="padding:2px;"> <select name='order' align="middle"> <option value='recipURL'{$sortfield}>recipURL</option> <option value='memberID'{$sortfield}>memberID</option> </select> <select name='ad' align="middle"> <option value='ASC'{$order}>ASC</option> <option value='DESC'{$order}>DESC</option> </select> <input type='submit' name='Go' value='Go' align="middle"> </td> </tr> </table> </td> </tr> </table> <table width='100%' cellpadding='2' cellspacing='0' border='0'> <tr> </tr> <tr> <td colspan="2"><hr color="#404040"></td> </tr> </table> </form>
Again, THANK YOU for your help
greg
-
Jan 15, 2005, 22:13 #7
- Join Date
- Nov 2004
- Location
- Parry Sound, ON
- Posts
- 725
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
In here:
PHP Code:<select name='order' align="middle">
<option value='recipURL'{$sortfield}>recipURL</option>
<option value='memberID'{$sortfield}>memberID</option>
</select>
<select name='ad' align="middle">
<option value='ASC'{$order}>ASC</option>
<option value='DESC'{$order}>DESC</option>
</select>
Change:
PHP Code:$order = $_GET['order']?$_GET['order']:'ASC' || 'DESC';
$sortfield = $_GET['sortfield']?$_GET['sortfield']:'memberID' || 'recipURL';
PHP Code:$order = $_GET['order']?$_GET['order']:'memberID' ;
$ad = $_GET['ad']?$_GET['ad']:'ASC';
PHP Code:$linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y' ORDER BY $sortfield $order LIMIT $offset, $limit ");
PHP Code:$linkCount = mysql_query("SELECT * FROM member_info WHERE verifiedURL = 'Y' ORDER BY $order $ad LIMIT $offset, $limit ");
-
Jan 16, 2005, 09:32 #8
- Join Date
- Jun 2004
- Location
- Florida
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you HardCoded,
everything works perfect now!
I appreciate your help
greg
Bookmarks