I am currently trying to do a Lyric page, just collections of lyrics. I use most of the search.php to lists Lyric Title etc.... This search script is part of whole big script which allow me to add song title Title, Singers sung the song, and Author, of the songs.
MY PROBLEM is this... I want to lists all the authors, and then click on the authors it will show all the songs wrote by that author. However, when I lists all the authors it became repeatative, it shows like 100 entry of the same authors. Example:
It will show like
John
John
John
John.
Eve
Eve
Eve
I want to write a scripts where it lists John and Eve only once and should look like
John (3)
Eve (3)
My php skill is not so good, I get by with some easy coding, but to do this. I don't know how. If any one can shed me the light or try to write one? I know this is hard and very sorry to have to post this, but I just want to see if it is even possible to do so.
I have included the search script below, if you want to take a look.
if($action == "search") {
if($searchstatus != "on") {
echo $lang_searchoff;
exit;
}
if(!$searchsubmit) {
$forumselect = "<select name=\"srchfid\">\n";
$forumselect .= "<option value=\"all\">$lang_textall</option>\n";
$queryforum = $db->query("SELECT * FROM $table_forums WHERE type='forum'");
while($forum = $db->fetch_array($queryforum)) {
$authorization = privfcheck($forum[private], $forum[userlist]);
if($authorization == "true") {
$forumselect .= "<option value=\"$forum[fid]\">$forum[name]</option>\n";
}
}
$forumselect .= "</select>";
eval("\$search = \"".template("lyric_misc_search")."\";");
echo $search;
}
if($searchsubmit || $page) {
if (!isset($page)) {
$page = 1;
$offset = 0;
$start = 0;
$end = 20;
} else {
$offset = ($page-1)*20;
$start = $offset;
$end = $offset+20;
}
$sql = "SELECT count(*), p.*, t.tid AS ttid, t.subject AS tsubject, f.fid, f.private AS fprivate, f.userlist AS fuserlist FROM $table_posts p, $table_threads t LEFT JOIN $table_forums f ON f.fid=t.fid WHERE p.tid=t.tid";
if($srchfrom == "0") {
$srchfrom = time();
}
$srchfrom = time() - $srchfrom;
if($srchtxt) {
$sql .= " AND (p.tacgia LIKE '%$srchtxt%' OR p.casi LIKE '%$srchtxt%' OR p.message LIKE '%$srchtxt%' OR p.subject LIKE '%$srchtxt%' OR t.subject LIKE '%$srchtxt')";
}
if($srchauthor != "all" && $srchauthor != "") {
$sql .= " AND p.author = '$srchtauthor'";
}
if($srchfrom) {
$sql .= " AND p.dateline >= '$srchfrom'";
}
$sql .=" GROUP BY dateline ORDER BY dateline DESC LIMIT $start,20";
$pagenum = $page+1;
eval("\$nextlink = \"".template("misc_search_nextlink")."\";");
$querysrch = $db->query($sql);
$postcount = 0;
while($post = $db->fetch_array($querysrch)) {
$authorization = privfcheck($post[fprivate], $post[fuserlist]);
if($authorization == "true") {
$date = date("$dateformat",$post[dateline]);
$time = date("$timecode",$post[dateline]);
$poston = "$date $lang_textat $time";
$post[tsubject] = stripslashes($post[tsubject]);
$postcount++;
eval("\$searchresults .= \"".template("misc_search_results_row")."\";");
}
}
if($postcount == "0") {
eval("\$searchresults = \"".template("misc_search_results_none")."\";");
}
eval("\$search = \"".template("misc_search_results")."\";");
echo $search;
}
}