rogue3
Regular


Joined: Jul 02, 2009
Posts: 71
|
Posted:
Thu Oct 01, 2009 7:07 am |
|
Hello!
I'm still tweaking this cool module. This time, I'm trying to add an "All" to the alphalist, so that when clicked on all reviews in the database are displayed. I've almost got it but am hung up on a few minor things.
1. Normally when I click on a letter, I get Reviews that begin with "A" displayed at the top. When I click on "All" I want it to say "All Reviews" but instead it says Reviews that begin with "%"
I added this, but it doesn't seem to be working:
Code: if($letter == All) {
echo "<i>All Reviews</i><br><br>";
}else {
echo "<i>"._REVIEWSLETTER." \"$letter\"</i></font><br><br>";
}
|
2. None of the sorting options (clicking the up/down arrows to sort a column) work on the All page. They work on all the letter pages, just not the all.
Here is the live page:
http://www.jeditemplearchives.com/content/modules.php?name=JReviews&rop=All
Here is the complete function. Perhaps someone can shed some light on where I'm going wrong...
Code:function alphalist($letter, $field, $order) {
global $admin, $bgcolor4, $sitename, $prefix, $multilingual, $currentlang, $db, $module_name;
// include ('header.php');
$letter = substr("$letter", 0,1);
if ($multilingual == 1) {
$querylang = "AND rlanguage='$currentlang'";
} else {
$querylang = "";
}
OpenTable();
echo "<font size=\"2\" face=\"Arial, Helvetica\"><center><b>Research Droids "._REVIEWS."</b><br>";
// echo "<i>"._REVIEWSLETTER." \"$letter\"</i><br><br>";
if($letter == All) {
echo "<i>All Reviews</i><br><br>";
}else {
echo "<i>"._REVIEWSLETTER." \"$letter\"</i></font><br><br>";
}
switch ($field) {
case "reviewer":
$result = $db->sql_query("SELECT id, title, hits, reviewer, score, date FROM ".$prefix."_jreviews WHERE UPPER(title) LIKE '$letter%' $querylang ORDER by reviewer $order");
break;
case "id":
$result = $db->sql_query("SELECT id, title, hits, reviewer, score, date FROM ".$prefix."_jreviews WHERE UPPER(title) LIKE '$letter%' $querylang ORDER by id $order");
break;
case "score":
$result = $db->sql_query("SELECT id, title, hits, reviewer, score, date FROM ".$prefix."_jreviews WHERE UPPER(title) LIKE '$letter%' $querylang ORDER by score $order");
break;
case "hits":
$result = $db->sql_query("SELECT id, title, hits, reviewer, score, date FROM ".$prefix."_jreviews WHERE UPPER(title) LIKE '$letter%' $querylang ORDER by hits $order");
break;
case "date":
$result = $db->sql_query("SELECT id, title, hits, reviewer, score, date FROM ".$prefix."_jreviews WHERE UPPER(title) LIKE '$letter%' $querylang ORDER by date $order");
break;
// default:
// $result = $db->sql_query("SELECT id, title, hits, reviewer, score FROM ".$prefix."_jreviews WHERE UPPER(title) LIKE '$letter%' $querylang ORDER by title $order");
// break;
default:
if($letter == All) {
// $result = $db->sql_query("SELECT id, title, hits, reviewer, score FROM ".$prefix."_jreviews ORDER by title ASC");
$result = $db->sql_query("SELECT id, title, hits, reviewer, score, date FROM ".$prefix."_jreviews WHERE $querylang ORDER by title $order");
}else {
$result = $db->sql_query("SELECT id, title, hits, reviewer, score, date FROM ".$prefix."_jreviews WHERE UPPER(title) LIKE '$letter%' $querylang ORDER by title $order");
}
break;
}
$numresults = $db->sql_numrows($result);
if ($numresults == 0) {
echo "<font size=\"2\" face=\"Arial, Helvetica\"><i><b>"._NOREVIEWS."</b></i></font><br><br>";
} elseif ($numresults > 0) {
echo "<TABLE BORDER=\"0\" width=\"100%\" CELLPADDING=\"2\" CELLSPACING=\"4\">
<tr>";
if (is_admin($admin))
echo "<td width=\"13%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=$letter&field=id&order=ASC\"><img src=\"images/up.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTASC."\"></a><B> "._ID." </B><a href=\"modules.php?name=$module_name&rop=$letter&field=id&order=DESC\"><img src=\"images/down.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTDESC."\"></a></font>
</td>";
echo "<td width=\"48%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"LEFT\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=$letter&field=title&order=ASC\"><img src=\"images/up.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTASC."\"></a><B> "._PRODUCTTITLE." </B><a href=\"modules.php?name=$module_name&rop=$letter&field=title&order=DESC\"><img src=\"images/down.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTDESC."\"></a></font>
</td>";
echo "<td width=\"22%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=$letter&field=reviewer&order=ASC\"><img src=\"images/up.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTASC."\"></a><B> "._REVIEWER2." </B><a href=\"modules.php?name=$module_name&rop=$letter&field=reviewer&order=desc\"><img src=\"images/down.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTDESC."\"></a></font>
</td>";
if (is_admin($admin))
echo "<td width=\"13%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=$letter&field=date&order=ASC\"><img src=\"images/up.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTASC."\"></a><B> "._ADDED2." </B><a href=\"modules.php?name=$module_name&rop=$letter&field=date&order=DESC\"><img src=\"images/down.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTDESC."\"></a></font>
</td>";
if (is_admin($admin))
echo "<td width=\"13%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=$letter&field=hits&order=ASC\"><img src=\"images/up.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTASC."\"></a><B> "._HITS." </B><a href=\"modules.php?name=$module_name&rop=$letter&field=hits&order=DESC\"><img src=\"images/down.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTDESC."\"></a></font>
</td>";
if (is_admin($admin))
echo "<td width=\"13%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=$letter&field=score&order=ASC\"><img src=\"images/up.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTASC."\"></a><B> "._RATING." </B><a href=\"modules.php?name=$module_name&rop=$letter&field=score&order=DESC\"><img src=\"images/down.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTDESC."\"></a></font>
</td>";
echo "<td width=\"17%\" bgcolor=\"$bgcolor4\">
<P ALIGN=\"CENTER\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=$letter&field=score&order=ASC\"><img src=\"images/up.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTASC."\"></a><B> "._SCORE2." </B><a href=\"modules.php?name=$module_name&rop=$letter&field=score&order=DESC\"><img src=\"images/down.gif\" border=\"0\" width=\"11\" height=\"11\" Alt=\""._SORTDESC."\"></a></font>
</td>";
echo "</tr>";
while($myrow = $db->sql_fetchrow($result)) {
$title = stripslashes(check_html($myrow["title"], "nohtml"));
$id = intval($myrow['id']);
$date = $myrow['date'];
$year = substr($date,0,4);
$month = substr($date,5,2);
$day = substr($date,8,2);
$fdate = date("F jS Y",mktime (0,0,0,$month,$day,$year));
$reviewer = stripslashes($myrow['reviewer']);
$email = stripslashes($myrow['email']);
$score = intval($myrow['score']);
$hits = intval($myrow['hits']);
echo "<tr>";
if (is_admin($admin))
echo "</font></td><td width=\"13%\" bgcolor=\"#EEEEEE\"><font size=\"2\" face=\"Arial, Helvetica\"><center>$id</center></font></td>";
echo "<td width=\"48%\" bgcolor=\"#EEEEEE\"><font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name&rop=showcontent&id=$id\">$title</a></font></td>";
echo "<td width=\"22%\" bgcolor=\"#EEEEEE\"><center><font size=\"2\" face=\"Arial, Helvetica\">$reviewer</center></font></td>";
if (is_admin($admin))
echo "</font></td><td width=\"13%\" bgcolor=\"#EEEEEE\"><font size=\"2\" face=\"Arial, Helvetica\"><center>$fdate</center></font></td>";
if (is_admin($admin))
echo "</font></td><td width=\"13%\" bgcolor=\"#EEEEEE\"><font size=\"2\" face=\"Arial, Helvetica\"><center>$hits</center></font></td>";
if (is_admin($admin))
echo "</font></td><td width=\"13%\" bgcolor=\"#EEEEEE\"><font size=\"2\" face=\"Arial, Helvetica\"><center>$score</center></font></td>";
echo "<td width=\"17%\" bgcolor=\"#EEEEEE\"><font size=\"2\" face=\"Arial, Helvetica\"><center>";
display_score($score);
}
echo "</tr></TABLE>";
echo "<font size=\"2\" face=\"Arial, Helvetica\"><br>$numresults "._TOTALREVIEWS."</font><br><br>";
}
echo "<font size=\"2\" face=\"Arial, Helvetica\"><a href=\"modules.php?name=$module_name\">"._RETURN2MAIN."</a></font>";
CloseTable();
}
|
Here's the alpha function, in case there is something that needs to be adjusted in it:
Code:function alpha() {
global $module_name, $bgcolor2;
$alphabet = array ("A","B","C","D","E","F","G","H","I","J","K","L","M",
// $alphabet = array ("All","A","B","C","D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0");
$num = count($alphabet) - 1;
echo "<center><font face=\"arial\" font size=\"2\">";
$counter = 0;
while (list(, $ltr) = each($alphabet)) {
echo "<a href=\"modules.php?name=$module_name&rop=$ltr\">$ltr</a>";
if ( $counter == round($num/2) ) {
echo "\n<br>\n";
} elseif ( $counter != $num ) {
echo " |\n";
}
$counter++;
}
// echo " </center><br><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><font size=\"2\" face=\"Arial, Helvetica\"><img src=\"/images/spacer.gif\" width=\"15\" height=\"3\" /></font></td></tr><tr><td bgcolor=\"#dddddd\"/images/spacer.gif\" width=\"15\" height=\"1\"></td></tr><tr><td><font size=\"2\" face=\"Arial, Helvetica\"><img src=\"/images/spacer.gif\" width=\"15\" height=\"2\" /></font></td></tr></table>\n\n\n";
echo "<br><br>";
}
|
Here is the only other place I refer to the 'All' down in the switches
Code: case "All":
alphalist('%', $field, $order);
break;
|
|
|
|