ok so i have this very simple code:
Code: $query = "SELECT search_keywords, COUNT(search_keywords) AS counter FROM phpbb_popsearch GROUP BY search_keywords ORDER BY counter DESC limit 5";
$res = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($res)) {
$term = $row["search_keywords"];
echo $term;
}
phpbb_popsearch is a table where i put the last search terms used in my forum search engine
this code will group together the same terms and list the 5 most popular terms
my problem is that the results will be ordered by "counter" which is the number of time a term has been found.
I want to get the 5 most popular results AND THEN, AFTER, list the results alphabetically
if i sort the results alphabetically right in the sql query (replacing "ORDER BY counter" by "ORDER BY search_keywords") it will not work correctly because it will not get the 5 most popular terms but just the 5 first terms, alphabetically sorting them and ignoring the number of times the term has been found
thanks for help
Delete Client 066 Earlywatch
Hi all,
Writing to the middle of a file
Hi I have a bit of a problem. Is there any way i can write some text to a middle of a text file. For instance on line 20? I know how to write text to the bottom of the file but not how i can get it to
HELP with mysql_real_escape_string
I'm looking to remove apostrophes completely when someone enters lyrics but don't have a clue how to do it.I've attached the 'submit lyric' page and the page where I approve submitted lyrics.(they're
"GROUP BY" in arrays
Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql query... But this time i'm working with an array...so i have an array that looks like thisCode:
mysq_num_rows
Hi,I want to use:Code: if(mysql_num_rows($ergebnis2)==2)how can the value 2, be retrieved from the database?example, lets say I have ifCode: (mysql_num_rows($ergebnis2)==$limit)$limit =
Help building / using array
First - this is a cross-posting, if this is wrong I apologise! What started out as a MySQL query question (original post http://www.phpfreaks.com/forums/index.php/topic,273323.0.html) has become a PHP
Xml parsing
I need a suggestion about parsing xml with multiply parts like pervious... i.e. different devices has a similar configuration, but how I can discern it by device? Code: <config><device
Beginner PHP code help
Hi I'm new to php but if someone could please read the question below and help it would be great.a)create an html page to enter a row number (1-6) in a textbox to choose a list of student records.b)
Email Form Syntax Issue
I need the TO: in email to display To: CEO instead of To: abc@mail.comHow to alter the script below?Code: <?PHP$to = "abc@mail.com";$subject = "subject"; $headers =
Procedure with variable number of columns
Hi, I have a procedure that looks like this: