[xiph-commits] r8328 - websites/dir.xiph.org

oddsock at motherfish-iii.xiph.org oddsock at motherfish-iii.xiph.org
Fri Dec 3 09:08:22 PST 2004


Author: oddsock
Date: 2004-12-03 09:08:21 -0800 (Fri, 03 Dec 2004)
New Revision: 8328

Modified:
   websites/dir.xiph.org/index.php
Log:
add a format search box


Modified: websites/dir.xiph.org/index.php
===================================================================
--- websites/dir.xiph.org/index.php	2004-12-03 13:19:02 UTC (rev 8327)
+++ websites/dir.xiph.org/index.php	2004-12-03 17:08:21 UTC (rev 8328)
@@ -66,6 +66,7 @@
 $start = $_GET["start"];
 $num = $_GET["num"];
 $sgenre = $_GET["sgenre"];
+$stype = $_GET["stype"];
 $search = $_GET["search"];
 
 $link = mysql_connect("localhost", $username, $password);
@@ -143,6 +144,22 @@
 	}
 	return "<a class=\"nav\" href=\"?start=$next&num=$pagesize$extra\"><font size=3>Next</font></a>";
 }
+function getContentTypes() {
+	$query = "select distinct(server_type) from server_details";
+	$result = mysql_query($query);
+	if (!$result) {
+		print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
+	}
+	 
+	$result_string = "Format Search<br>";
+	$result_string .= "<select name='stype'>";
+	$result_string .= "<option value='' selected>";
+	while ($row = mysql_fetch_row($result)) {
+		$result_string .= "<option value='$row[0]'>$row[0]";
+	}
+	$result_string .= "</select>";
+	return $result_string;
+}
 function getTotalListeners() {
 	$query = "select sum(listeners) from servers";
 	$result = mysql_query($query);
@@ -295,12 +312,19 @@
 ';
  
 $query = "select id, server_name, listeners from servers order by rank desc";
+$subquery = "";
 
 if ($sgenre) {
 	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and b.genre like '%$sgenre%' group by a.id, a.server_name, a.listeners order by a.rank desc";
+	$subquery = "and genre like '%$sgenre%'";
 }
+if ($stype) {
+	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and b.server_type like '%$stype%' group by a.id, a.server_name, a.listeners order by a.rank desc";
+	$subquery = "and server_type like '%$stype%'";
+}
 if ($search) {
 	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and (a.server_name like '%$search%' or b.description like '%$search%' or b.current_song like '%$search%' or b.genre like '%$search%') group by a.id, a.server_name, a.listeners order by a.rank desc";
+	$subquery = "and (server_name like '%$search%' or description like '%$search%' or current_song like '%$search%' or genre like '%$search%')";
 }
 $result = mysql_query($query);
 if (!$result) {
@@ -344,7 +368,7 @@
 	}
 	if ($server_name != "") {
 		$all_listeners = $listeners;
-		$query = "select description, genre, url, current_song, listen_url, server_type, bitrate, samplerate, channels, listeners+0, parent_id, id from server_details where parent_id = $id";
+		$query = "select description, genre, url, current_song, listen_url, server_type, bitrate, samplerate, channels, listeners+0, parent_id, id from server_details where parent_id = $id $subquery";
 		
 		$streamDetailsLine = "";
 		$result2 = mysql_query($query);
@@ -425,6 +449,7 @@
 <option value="70s">70s
 </select>
 <br>
+<? print getContentTypes(); ?><br>
 Freeform Search<br><input name=search style="font-size:8pt">
 <input type=Submit value=Search>
 </form>



More information about the commits mailing list