Text wechseln lassen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Text wechseln lassen

    Hi leute!

    habe diesen code für meine Shoutbox:
    PHP Code:
    <Title>Shoutbox</Title>
    <?
      $tablewidth = 200;
      $showcomments = 5;
      $file = "shout.txt";    
      $maxlength_name = "40";
      $maxlength_comment = "600";
      $break_name = "30";            
      $break_comment = "60";

      echo "
    <table width='$tablewidth' cellspacing='2' cellpadding='0' border='0'>
      <form action='$PHP_SELF?show=$show' method='post' name='shoutbox'>
        <tr>
          <td>
            <input type='text' value='Name' name='input_name' size='18' maxlength='$maxlength_name' 
    onFocus=\"javascript:if(document.shoutbox.input_name.value=='Name')
    document.shoutbox.input_name.value='';\"><br>
            <input type='text' value='Kommentar' name='input_comment' size='18' 
    maxlength='$maxlength_comment' onFocus=\"javascript:if
    (document.shoutbox.input_comment.value=='Kommentar')
    document.shoutbox.input_comment.value='';\">
          </td>
          <td align='center'><input type='submit' value='Go!'></td>
        </tr>
        <tr>
          <td colspan='2'>
            <hr>
      ";

      function str_break($str, $maxlen){
        $nobr = 0;
        $len = strlen($str);
        for ($i = 0; $i<$len; $i++){
          if (($str[$i]!=' ') && ($str[$i]!='-') && ($str[$i]!="\n"))
            $nobr++;
          else{
            $nobr = 0;
            if($maxlen+$i>$len){
              $str_br .= substr($str, $i);
              break;
            }
          }
          if ($nobr>$maxlen){
            $str_br .= ' '.$str[$i];
            $nobr = 1;
          }
          else
            $str_br .= $str[$i];
        }
        return $str_br;
      }

      if($show == "all") echo "<a href='$PHP_SELF'>Neueste Kommentare anzeigen</a><hr>";
      else echo "<a href='$PHP_SELF?show=all'>Alle Kommentare zeigen</a><hr>";

      if($input_name != "Name" && $input_name != "" && $input_comment != "Kommentar" && $input_comment != ""){

        $tmp = fopen($file,"r");
        while(!feof($tmp)){
          $row = fgets($tmp,999999);
          list($tmpname,$tmpcomment) = split("\|",$row);
          if($tmpname != "" && $tmpcomment != ""){
            $name = $tmpname;
            $comment = $tmpcomment;
            $comment = str_replace("\n","",$comment);
          }
        }
        fclose($tmp);

        $input_name = str_break($input_name, $break_name);
        $input_name = str_replace("<","&lt;",$input_name);
        $input_name = str_replace(">","&gt;",$input_name);
        $input_name = stripslashes($input_name);
        $input_comment = str_break($input_comment, $break_comment);
        $input_comment = str_replace("<","&lt;",$input_comment);
        $input_comment = str_replace(">","&gt;",$input_comment);
        $input_comment = stripslashes($input_comment);

        if($name != $input_name || $comment != $input_comment){
          $tmp = fopen($file, "a");
          fputs($tmp,"$input_name|$input_comment\n");
          fclose($tmp);
        }
      }

      $names = array();
      $comments = array();
      $tmp = fopen($file,"r");
      while(!feof($tmp)){
        $row = fgets($tmp,999999);
        list($name,$comment) = split("\|",$row);
        if($name != ""){
          array_push($names,$name);
          array_push($comments,$comment);
        }
      }
      fclose($tmp);
      $names = array_reverse($names);
      $comments = array_reverse($comments);

      if($show == "all")
        $max = count($names);
      else
        $max = $showcomments;

      for($i=0; $i<$max; $i++)
        echo "<b>$names[$i]</b><br> $comments[$i]<br><br>\n";

      echo "
          </td>
        </tr>
      </form>
    </table>
      ";
    ?>
    Das funktioniert auch wunderbar, aber ich würde gerne den Text einzeln erscheinen lassen, ist das möglich? Also ich hab hier ne schleife die alle datensäte anzeigt, möchte aber, dass so alle paar sekunden der datensatz wechselt. Kann mir da jemand bei helfen???

    gruß und Danke imVoraus Mülla
    Last edited by mülla; 24-10-2004, 15:16.

  • #2
    tja, da wärst du dann beim einsatz von java gelandet, nämlich clientseitig

    Comment


    • #3
      thx für dein Antwort... aber kannst du mir auch sagen wie das geht?

      Comment


      • #4
        Falsches Forum! *verschieb*

        Comment


        • #5
          mmh... kann mir keiner helfen?

          Comment


          • #6
            schau mal hier: http://www.php-resource.de/forum/sho...&highlight=404

            Comment


            • #7
              schau mal bei selfhtml nach setTimeout

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

              Comment

              Working...
              X