File:  [mozdev] / chameleon / www / test.html
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Sun Feb 18 16:42:49 2001 UTC (19 years, 1 month ago) by petejc
Branches: MAIN
CVS tags: HEAD
this is a test

--pete

    1: <?php
    2:   require(PHP_INC.CONNECT);
    3: 
    4:   if (!isset($action)||$action=="form") {
    5:     
    6:     include "form_template.php";
    7:   
    8:     $query="SELECT * FROM country ORDER BY name";
    9:     $countries=mysql_query($query);
   10:     
   11:     $query="SELECT * FROM language ORDER BY name";
   12:     $languages=mysql_query($query);
   13:     
   14:     $query="SELECT * FROM category ORDER BY name";
   15:     $categories=mysql_query($query);
   16:   
   17:     $country_option_list="";
   18:     while ($country=mysql_fetch_array($countries)) {
   19:        $country_option_list.="<option value=\"$country[code]\">$country[name]</option>\n";
   20:     }
   21:     $language_option_list="";
   22:     while ($language=mysql_fetch_array($languages)) {
   23:        $language_option_list.="<option value=\"$language[code]\">$language[name]</option>\n";
   24:     }
   25:     $category_option_list="";
   26:     while ($category=mysql_fetch_array($categories)) {
   27:        $category_option_list.="<option value=\"$category[id]\">$category[name]</option>\n";
   28:     }
   29:     
   30:     $html=str_replace("%countries%",$country_option_list,$html);
   31:     $html=str_replace("%languages%",$language_option_list,$html);
   32:     $html=str_replace("%categories%",$category_option_list,$html);
   33:     
   34:     echo($html);
   35:   
   36:   } else if ($action=="dosearch") {
   37:     
   38:     if ($country && $country!="all") {
   39:       $andcountry=" AND country='$country'";
   40:     }
   41:     if ($language && $language!="all") {
   42:       $andlanguage=" AND language='$language'"; 
   43:     }
   44:     if ($category && $category!="all") {
   45:       $andcategory=" AND category='$category'"; 
   46:     }
   47:     //$query="SELECT * FROM sherlock WHERE name LIKE '%$name%'".$andcountry.$andlanguage.$andcategory." ORDER BY name";
   48:                 $query="SELECT *
   49:                         FROM sherlock,category
   50:                         WHERE sherlock.category=category.id AND sherlock.name
   51:                           LIKE '%$name%'".$andcountry.$andlanguage .$andcategory."
   52:                         ORDER BY category.name,sherlock.name";
   53:     $res=mysql_query($query);
   54:     $numrows=mysql_num_rows($res);
   55:     if ($numrows>0) {
   56:       while ($item=mysql_fetch_array($res)) {
   57:                                 if ($item[13] != $prevcat) {
   58:                             if ($catfirsttime == "no") {
   59:                                     echo("    </ul>\n  </li>\n");
   60:                                   }
   61:                                   else {
   62:                                           $thelist = "<ol id=\"plugins\">\n";
   63:                                     echo($thelist);
   64:                                         $catfirsttime = "no";
   65:                                   }
   66:                                         $thiscat = "  <li class=\"category\">\n    $item[14]\n    <ul>\n";
   67:                                   echo($thiscat);
   68:                                   $prevcat = $item[13];
   69:                                 }
   70:         displayitem($item);
   71:       }
   72:                         echo("    </ul>\n  </li>\n</ol>\n");
   73:       echo("<p>$numrows plugins found.\n</p>");
   74:       
   75:     } else {
   76:       $nothingfound="<p><b>Nothing found.</b></p>\n";
   77:       echo($nothingfound); 
   78:     }
   79:     
   80:   }
   81:   function displayitem($item) {
   82:         /*0 = id
   83:           1 = plugin name
   84:                 2 = icon type
   85:                 3 = long url
   86:                 4 = short url
   87:     5 = author
   88:                 6 = date
   89:                 7 = category number
   90:                 8 = country code
   91:                 9 = language code
   92:                 10 = beta
   93:     11 = public
   94:                 12 = comment
   95:                 13 = category number
   96:                 14 = category name*/
   97: 
   98:           $startlist = "      <li style=\"list-style-image: url(http://sherlock.mozdev.org/$item[0].$item[2])\">\n";
   99:                 $address = "        (<a href=\"http://$item[3]\">$item[4]</a>)\n";
  100:                 if ($item[5]) {
  101:                   $author = "        by $item[5]\n";
  102:                 }
  103:                 else {
  104:                   $author = "";
  105:                 }
  106:                 $install = "        <a href=\"javascript:addEngine('$item[0]','$item[2]')\">$item[1]</a> [$item[9]-$item[8]]\n";
  107:                 $endlist = "      </li>\n";
  108:                 echo($startlist);
  109:     echo($install);
  110:     echo($address . $author);
  111:     echo($endlist); 
  112:   }
  113: 
  114: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>