Mysql Tooltip

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Mysql Tooltip

    Hallo,

    Ich habe eine Datenbank mit Informationen, welche als Tooltip angezeigt werden sollen.

    Ich benutze nun folgendes Script, welches automatisch die Keywords dann in Tooltips verwandelt.

    php_tip_class.php

    PHP-Code:
    class php_tip {

    var 
    $subject "";
    var 
    $what_is_the "What is the";
    var 
    $target "_self";
    var 
    $show_limit true;
    var 
    $word_limit "1";  //One keyword one times show.You can set it two or three.. times.
                            //if show_limit = false; this option not important and all words will show.

          
    function tip($subject$what_is_the$target$show_limit$word_limit) {
             
    $this->subject "<div id=\"container\">".$subject."</div>";
             
    $this->what_is_the $what_is_the;
             
    $this->target $target;
             
    $this->show_limit $show_limit;
             
    $this->word_limit $word_limit;
             
    $this->get_data();
          }

          function 
    a_link($a_color="yellow"$a_decoration$hover_color="red",$hover_decoration,
          
    $hover_background="lightyellow") {
             echo 
    "a.tt{position:relative; z-index:24; color:$a_color; text-decoration:$a_decoration;}";
             echo 
    "a.tt span{display: none;}";
             echo 
    "a.tt:hover{z-index:25;color:$hover_color;text-decoration:$hover_decoration;
             background:
    $hover_background;}";
          }

          function 
    tip_top($opacity="90"$top_fontface="Arial,sans-serif"$top_fontsize="12px",
          
    $top_fontcolor="yellow"$top_fontweight="bold"$top_padding="30px 8px 0"$top_image="img.jpg"){

             echo 
    "<style type=\"text/css\">";

             
    ///// Cut body part and insert it your css file.
             
    echo "body{font-family:Arial; font-size:14px; background: #FFFFFF; color: #333333;}";
             
    ///// Cut body part and insert it your css file.

             
    echo "div#container{margin:0 auto}";
             echo 
    "h1{ color: #F60; margin: 1em 0 0; letter-spacing: -2px; }";
             echo 
    "p{margin: 0 0 1.7em; }";

             echo 
    "a.tt:hover span.tooltip{display:block;position:absolute;top:0px;
             left:0;padding:15px 0 0 0;width:400px;"
    ;
             echo 
    "color: #00FFF7;text-align:left;filter: alpha(opacity:$opacity);KHTMLOpacity: 0.$opacity;
             MozOpacity: 0.
    $opacity;";
             echo 
    "opacity: 0.$opacity;}";

             echo 
    "a.tt:hover span.top{display:block;padding:$top_padding;background: url($top_image) no-repeat top;";
             echo 
    "font-size:$top_fontsize;font-family:$top_fontface;font-weight:$top_fontweight;color:$top_fontcolor;}";
          }

          function 
    tip_middle($mid_fontface="Arial,sans-serif"$mid_fonsize="12px"$mid_fontcolor="black",
          
    $mid_fontweight="bold"$mid_padding="0 8px"$mid_image="bubble_filler.gif"){

             echo 
    "a.tt:hover span.middle{display: block;padding: $mid_padding;font-size:$mid_fonsize;
             font-family:
    $mid_fontface;font-weight:$mid_fontweight;color:$mid_fontcolor;";
             echo 
    "background: url($mid_image) repeat bottom;}";
          }

          function 
    tip_test($tester_fontface="Arial,sans-serif"$tester_fonsize="12px"$tester_fontcolor="white",
          
    $tester_fontweight="bold"$tester_padding="0 8px"$tester_image="bubble_filler.gif"){

             echo 
    "a.tt:hover span.middle{display: block;padding: $tester_padding;font-size:$mid_fonsize;
             font-family:
    $tester_fontface;font-weight:$tester_fontweight;color:$tester_fontcolor;";
             echo 
    "background: url($tester_image) repeat bottom;}";
          }

          function 
    tip_bottom($bot_fontface="Arial,sans-serif"$bot_fonsize="9px"$bot_fontcolor="#548912",
          
    $bot_fontweight="bold"$bot_padding="3px 8px 10px"$bot_image="bubble.gif") {

             echo 
    "a.tt:hover span.bottom{display:block;padding:$bot_padding;font-family:$bot_fontface;
             font-size:
    $bot_fonsize;font-weight:$bot_fontweight;color:$bot_fontcolor;";
             echo 
    "background: url($bot_image) no-repeat bottom;}";
             echo 
    "</style>";
          }

         function 
    get_data(){
             
    $key_sql mysql_query("SELECT keyword FROM dic_data") or die (mysql_error());
             
    $i 0;
             
    $array1_keywords = array();
             while (
    $row mysql_fetch_array($key_sql)) {
             
    extract($row);
             
    $array1_keywords[$i++] = $keyword;
             }
         
    $this->found_keywords($array1_keywords);
         }

         function 
    found_keywords($found_keywords){
          
    //found keyword
             
    for ($i=0$i<count($array1_keywords); $i++) {
             
    preg_match_all("/".$array1_keywords[$i]."/",$subject,$outPREG_PATTERN_ORDER);
             
    $found_keywords[$i] = $out[0][0];
             }
             
    //match keyword
             //not useful -> $found_keywords = array_uintersect($array1_keywords, $array2_body, "strcasecmp");
          
    $this->find_real_keywords($found_keywords);
         }

         function 
    find_real_keywords($found_keywords){
             
    $patterns = array();
             
    $replacements = array();
             for(
    $i=0$i<=count($found_keywords) - 1$i++) {
             
    $key_row mysql_query("SELECT * FROM dic_data WHERE keyword = '$found_keywords[$i]'");
             while (
    $row mysql_fetch_assoc($key_row)) {
             
    extract($row);
             
    $capital_keyword ucwords($keyword);
             
    //bu is kontrolden cikti.some turkish note.

             //don't change this section!!
             
    $patterns[$i] = "/\b".$found_keywords[$i]."\b/i"//case sensitive, word boundary problem fixed.
             
    $replacements[$i] = "<a href=\"$foot_note\" target=\"$this->target\" class=\"tt\">$found_keywords[$i]<span class=\"tooltip\"><span class=\"top\">$this->what_is_the $capital_keyword?</span><span class=\"middle\">$description</span><span class=\"test\">$Sonstiges</span><span class=\"bottom\">$foot_note</span></span></a>";

        }  
    //end while.
        
    }  //end for

        
    $this->replace_all_words($patterns$replacements);
        }  
    //end real_key function.


        
    function replace_all_words($patterns$replacements) {
        
    //replace and echo subject.
             
    if($this->show_limit == true) {
             echo 
    preg_replace($patterns$replacements$this->subject$this->word_limit);
             } elseif (
    $this->show_limit == false) {
             echo 
    preg_replace($patterns$replacements$this->subject);
             }
        }


    //end class
    ?> 
    Ich versuche nun meine Tabellenspalte "Sonstiges" anzuzeigen und habe dafür eben die Funktion tip_test erstellt. Anzeigen lasse ich mir dann das Ganze so:

    Code:
    <span class=\"test\">$Sonstiges</span>
    Passiert allerdings nichts. Der Spalteninhalt wird nicht angezeigt im Tooltip. Wenn ich hingegen eine andere Klasse benutze, wie

    Code:
    <span class=\"top\">$Sonstiges</span>
    funktioniert es.


    Danke für die Hilfe.

  • #2
    Dann sieht das nach einem CSS-Problem aus. Online-Beispiel verfügbar?

    Peter
    Nukular, das Wort ist N-u-k-u-l-a-r (Homer Simpson)
    Meine Seite

    Kommentar

    Lädt...
    X