Avatar billede xvid Seniormester
25. januar 2004 - 00:29 Der er 12 kommentarer og
1 løsning

Tilføje smileys til tagwall

Hej
Er der nogen her der kan hjælpe mig med at tilføje 7 smileys til denne tagwall?

på forhånd tak

<html>
<head>
<style type='text/css'>
body {
  font-family: Trebuchet MS;
  color: #000000;
  font-size: 10pt;
}
INPUT {
  border: 1px solid;
  color: #000000;
}
TEXTAREA {
  border: 1px solid;
  color: #000000;
}
A {
  text-decoration: none;
  color: #000000;
}
A:hover {
  text-decoration: underline;
}
</style>
  <title>Tagwall made by Kasper Andersen</title>
</head>
<body>
<form method='post' action=''>

<table cellspacing='3'>
  <tr>
    <td><input type='text' name='name' value='Name' onfocus="if(this.value=='Name')this.value='';" onblur="if(this.value=='')this.value='Name';" size='22'></td>
  </tr>
  <tr>
    <td><input type='text' name='email' value='E-mail' onfocus="if(this.value=='E-mail')this.value='';" onblur="if(this.value=='')this.value='E-mail';" size='22'></td>
  </tr>
  <tr>
    <td><textarea cols='30' rows='7' name='text'></textarea></td>
  </tr>
  <tr>
    <td><input type='submit' name='send' value='Post'></form></td>
  </tr>
</table>
<br><br>

<?php

//MySQL server configuration
$host = "localhost"; //Enter the address to your MySQL server
$user = "knaldhat"; //Enter the user to your MySQL server
$pass = "fdokty54"; //Enter the password to your user
$db = "knaldhat"; //Enter the database on your MySQL server where you created the table from the structure.sql

//Do not modify anything under this line!

//Get the input typed in the form
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];
$time = date("d/m-Y H:i:s");

//If nothing was typed in the name field, then the Name will be replaced with 'anonymous'
if ($_POST['name'] == "Name") {
    $name = "Anonymous";
}

//If nothing was typed in the E-mail field, then the E-mail will be replaced with null@null
if ($_POST['email'] == "E-mail") {
    $email = "null@null";
}

//Connect to the MySQL server
mysql_connect("$host", "$user", "$pass");

//Select a database
mysql_select_db($db);

//If the text field isn't empty, then this code will be executed:
//If an URL was typed in the text field, then it will be replaced with <a href='http://somedomain.com'>http://somedomain.com</a>
//If an < or > has been typed, it will be replaced with &lt; or &gt;
//Insert the data into the MySQL database
if(!empty($_POST['text'])){
    $text = ereg_replace("<", "&lt;", $text);
    $text = ereg_replace(">", "&gt;", $text);
    $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $text);
    $insertSQL = "insert into tagwall (name, email, time, text) values ('$name', '$email', '$time', '$text')";
    mysql_query($insertSQL);
}

//Get all the data from the MySQL database, sort by the row 'id' and limit the rows that's being printed to 20
//Make an array from the $result variable
//Convert the 'new line's to <br>
$result = mysql_query("SELECT * FROM tagwall ORDER BY id DESC LIMIT 20") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
    echo "<font family='Trebuchet MS, sans-serif' size='2'><b><a href='mailto:".$row['email']."'>".$row['name']."</a></b> - ".$row['time']."<br>";
    echo nl2br($row['text']);
    echo "<br><br>";
}

//Close the connection to the MySQL server
mysql_close();
?>

<br><br>

</body>
</html>
Avatar billede martinbk Nybegynder
25. januar 2004 - 00:36 #1
en simpel måde er blot at gøre noget alla følgende

$text = ereg_replace(":)", "<img src='smiley.gif'>", $text);
Avatar billede detox Nybegynder
25. januar 2004 - 00:37 #2
Det er normalt en dårlig idé at offentliggøre sit password!
Avatar billede spunk13 Nybegynder
25. januar 2004 - 00:40 #3
Sættes ind efter $text = ereg_replace("<", "&lt;", $text);
    $text = ereg_replace(">", "&gt;", $text);
    $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $text);

>>>

$emotearr = array(":)",
":(",
":'(",
":D",
":P",
";)"
);
$emotetag = array("<img src='emoticons/smile.gif'>",
"<img src='emoticons/cry.gif'>",
"<img src='emoticons/cry.gif'>",
"<img src='emoticons/smilebig.gif'>",
"<img src='emoticons/smiletongue.gif'>",
"<img src='emoticons/smilewink.gif'>"
);

$text = str_replace($emotearr, $emotetag, $text);
Avatar billede xvid Seniormester
25. januar 2004 - 00:44 #4
spunk13 >> jeg har ikke særligt meget forstand på det her, kunne du smide hele koden her ind, så jeg ikke laver noget rod?
Avatar billede xvid Seniormester
25. januar 2004 - 00:46 #5
mit hotel er nede, kunne jeg få én af jer til at smide det online så jeg kan se hvordan det set ud?
Avatar billede spunk13 Nybegynder
25. januar 2004 - 00:49 #6
<html>
<head>
<style type='text/css'>
body {
  font-family: Trebuchet MS;
  color: #000000;
  font-size: 10pt;
}
INPUT {
  border: 1px solid;
  color: #000000;
}
TEXTAREA {
  border: 1px solid;
  color: #000000;
}
A {
  text-decoration: none;
  color: #000000;
}
A:hover {
  text-decoration: underline;
}
</style>
  <title>Tagwall made by Kasper Andersen</title>
</head>
<body>
<form method='post' action=''>

<table cellspacing='3'>
  <tr>
    <td><input type='text' name='name' value='Name' onfocus="if(this.value=='Name')this.value='';" onblur="if(this.value=='')this.value='Name';" size='22'></td>
  </tr>
  <tr>
    <td><input type='text' name='email' value='E-mail' onfocus="if(this.value=='E-mail')this.value='';" onblur="if(this.value=='')this.value='E-mail';" size='22'></td>
  </tr>
  <tr>
    <td><textarea cols='30' rows='7' name='text'></textarea></td>
  </tr>
  <tr>
    <td><input type='submit' name='send' value='Post'></form></td>
  </tr>
</table>
<br><br>

<?php

//MySQL server configuration
$host = "localhost"; //Enter the address to your MySQL server
$user = "knaldhat"; //Enter the user to your MySQL server
$pass = "fdokty54"; //Enter the password to your user
$db = "knaldhat"; //Enter the database on your MySQL server where you created the table from the structure.sql

//Do not modify anything under this line!

//Get the input typed in the form
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];
$time = date("d/m-Y H:i:s");

//If nothing was typed in the name field, then the Name will be replaced with 'anonymous'
if ($_POST['name'] == "Name") {
    $name = "Anonymous";
}

//If nothing was typed in the E-mail field, then the E-mail will be replaced with null@null
if ($_POST['email'] == "E-mail") {
    $email = "null@null";
}

//Connect to the MySQL server
mysql_connect("$host", "$user", "$pass");

//Select a database
mysql_select_db($db);

//If the text field isn't empty, then this code will be executed:
//If an URL was typed in the text field, then it will be replaced with <a href='http://somedomain.com'>http://somedomain.com</a>
//If an < or > has been typed, it will be replaced with &lt; or &gt;
//Insert the data into the MySQL database
if(!empty($_POST['text'])){
    $text = ereg_replace("<", "&lt;", $text);
    $text = ereg_replace(">", "&gt;", $text);
    $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $text);

$emotearr = array(":)",
":(",
":'(",
":D",
":P",
";)"
);
$emotetag = array("<img src='emoticons/smile.gif'>",
"<img src='emoticons/cry.gif'>",
"<img src='emoticons/cry.gif'>",
"<img src='emoticons/smilebig.gif'>",
"<img src='emoticons/smiletongue.gif'>",
"<img src='emoticons/smilewink.gif'>"
);

$text = str_replace($emotearr, $emotetag, $text);

    $insertSQL = "insert into tagwall (name, email, time, text) values ('$name', '$email', '$time', '$text')";
    mysql_query($insertSQL);
}

//Get all the data from the MySQL database, sort by the row 'id' and limit the rows that's being printed to 20
//Make an array from the $result variable
//Convert the 'new line's to <br>
$result = mysql_query("SELECT * FROM tagwall ORDER BY id DESC LIMIT 20") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
    echo "<font family='Trebuchet MS, sans-serif' size='2'><b><a href='mailto:".$row['email']."'>".$row['name']."</a></b> - ".$row['time']."<br>";
    echo nl2br($row['text']);
    echo "<br><br>";
}

//Close the connection to the MySQL server
mysql_close();
?>

<br><br>

</body>
</html>


----

Du kan selvfølgelig selv ændre på stien til billedefilerne og også selv tilføje og fjerne nogen. Det der sker er at det første i $emotearr bliver erstattet med det første i $emotetag. Så bare du sørger for at der er lige mange smileys som der er tags, skulle der ikke være noget problem.
Avatar billede xvid Seniormester
25. januar 2004 - 01:03 #7
spunk13 >> kunne du gøre sådan at man kan se dem nedenunder når man kommer ind på siden?


<html>
<head>
<style type='text/css'>
body {
  font-family: Trebuchet MS;
  color: #000000;
  font-size: 10pt;
}
INPUT {
  border: 1px solid;
  color: #000000;
}
TEXTAREA {
  border: 1px solid;
  color: #000000;
}
A {
  text-decoration: none;
  color: #000000;
}
A:hover {
  text-decoration: underline;
}
</style>
  <title>Tagwall made by Kasper Andersen</title>
</head>
<body>
<form method='post' action=''>

<table cellspacing='3' width="313">
  <tr>
    <td width="162">navn</td>
    <td width="158">e-mail</td>
  </tr>
  <tr>
    <td width="162"><input type='text' name='name' value='Name' onfocus="if(this.value=='Name')this.value='';" onblur="if(this.value=='')this.value='Name';" size='22'></td>
    <td width="158"><input type='text' name='email' value='E-mail' onfocus="if(this.value=='E-mail')this.value='';" onblur="if(this.value=='')this.value='E-mail';" size='22'></td>
  </tr>
  <tr>
    <td width="328" colspan="2">besked</td>
  </tr>
  <tr>
    <td width="328" colspan="2"><textarea cols='38' rows='7' name='text'></textarea></td>
  </tr>
  <tr>
    <td width="328" colspan="2"><input type='submit' name='send' value='Post'></form></td>
  </tr>
  <tr>
    <td width="328" colspan="2"><img src='emoticons/smile.gif'>&nbsp; <img src='emoticons/cry.gif'>&nbsp;
      <img src='emoticons/cry.gif'>&nbsp; <img src='emoticons/smilebig.gif'>&nbsp;
      <img src='emoticons/smiletongue.gif'>&nbsp; <img src='emoticons/smilewink.gif'></td>
  </tr>
</table>
<br><br>

<?php

//MySQL server configuration
$host = "localhost"; //Enter the address to your MySQL server
$user = "knaldhat"; //Enter the user to your MySQL server
$pass = "fdokty54"; //Enter the password to your user
$db = "knaldhat"; //Enter the database on your MySQL server where you created the table from the structure.sql

//Do not modify anything under this line!

//Get the input typed in the form
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];
$time = date("d/m-Y H:i:s");

//If nothing was typed in the name field, then the Name will be replaced with 'anonymous'
if ($_POST['name'] == "Name") {
    $name = "Anonymous";
}

//If nothing was typed in the E-mail field, then the E-mail will be replaced with null@null
if ($_POST['email'] == "E-mail") {
    $email = "null@null";
}

//Connect to the MySQL server
mysql_connect("$host", "$user", "$pass");

//Select a database
mysql_select_db($db);

//If the text field isn't empty, then this code will be executed:
//If an URL was typed in the text field, then it will be replaced with <a href='http://somedomain.com'>http://somedomain.com</a>
//If an < or > has been typed, it will be replaced with &lt; or &gt;
//Insert the data into the MySQL database
if(!empty($_POST['text'])){
    $text = ereg_replace("<", "&lt;", $text);
    $text = ereg_replace(">", "&gt;", $text);
    $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $text);

$emotearr = array(":)",
":(",
":'(",
":D",
":P",
";)"
);
$emotetag = array("<img src='emoticons/smile.gif'>",
"<img src='emoticons/cry.gif'>",
"<img src='emoticons/cry.gif'>",
"<img src='emoticons/smilebig.gif'>",
"<img src='emoticons/smiletongue.gif'>",
"<img src='emoticons/smilewink.gif'>"
);

$text = str_replace($emotearr, $emotetag, $text);

    $insertSQL = "insert into tagwall (name, email, time, text) values ('$name', '$email', '$time', '$text')";
    mysql_query($insertSQL);
}

//Get all the data from the MySQL database, sort by the row 'id' and limit the rows that's being printed to 20
//Make an array from the $result variable
//Convert the 'new line's to <br>
$result = mysql_query("SELECT * FROM tagwall ORDER BY id DESC LIMIT 20") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
    echo "<font family='Trebuchet MS, sans-serif' size='2'><b><a href='mailto:%22.$row[' email']."'>".$row['name']."</a></b> - ".$row['time']."<br>";
    echo nl2br($row['text']);
    echo "<br><br>";
}

//Close the connection to the MySQL server
mysql_close();
?>

<br><br>

</body>
</html>
Avatar billede xvid Seniormester
25. januar 2004 - 01:06 #8
-> med muligheden for at tilføje direkte. Sorry hvis jeg er meget besværlig
Avatar billede xvid Seniormester
25. januar 2004 - 01:10 #9
Avatar billede spunk13 Nybegynder
25. januar 2004 - 13:45 #10
Jeg har ikke mulighed for selv at teste det igennem:

<?php

$emotearr = array(
":)",
":(",
":'(",
":D",
":P",
";)"
);
$emotepath = array(
"emoticons/smile.gif",
"emoticons/cry.gif",
"emoticons/cry.gif",
"emoticons/smilebig.gif",
"emoticons/smiletongue.gif",
"emoticons/smilewink.gif"
);

?>

<html>
<head>
<style type='text/css'>
body {
  font-family: Trebuchet MS;
  color: #000000;
  font-size: 10pt;
}
INPUT {
  border: 1px solid;
  color: #000000;
}
TEXTAREA {
  border: 1px solid;
  color: #000000;
}
A {
  text-decoration: none;
  color: #000000;
}
A:hover {
  text-decoration: underline;
}
</style>
  <title>Tagwall made by Kasper Andersen</title>
<script type='text/javascript'>

function indsaetSmiley(smiley) {

document.getElementById('text').value=document.getElementById('text').value+smiley;

}

</script>
</head>
<body>
<form method='post' action=''>

<table cellspacing='3' width="313">
  <tr>
    <td width="162">navn</td>
    <td width="158">e-mail</td>
  </tr>
  <tr>
    <td width="162"><input type='text' name='name' value='Name' onfocus="if(this.value=='Name')this.value='';"

onblur="if(this.value=='')this.value='Name';" size='22'></td>
    <td width="158"><input type='text' name='email' value='E-mail' onfocus="if(this.value=='E-mail')this.value='';"

onblur="if(this.value=='')this.value='E-mail';" size='22'></td>
  </tr>
  <tr>
    <td width="328" colspan="2">besked</td>
  </tr>
  <tr>
    <td width="328" colspan="2"><textarea cols='38' rows='7' name='text'></textarea></td>
  </tr>
  <tr>
    <td width="328" colspan="2"><input type='submit' name='send' value='Post'></form></td>
  </tr>
  <tr>
    <td width="328" colspan="2">
<?php

for ($i = 0; $i < count($emotearr); $i++) {
echo "<img src='".$emotepath[$i]."' onClick=''indsaetSmiley(\'".$emotearr[$i]."\');'>&nbsp; ";
}

for ($i = 0; $i < count($emotepath); $i++) {
$emotepath[$i] = "<img src='".$emotepath[$i]."'>";
}

?></td>
  </tr>
</table>
<br><br>

<?php

//MySQL server configuration
$host = "localhost"; //Enter the address to your MySQL server
$user = "knaldhat"; //Enter the user to your MySQL server
$pass = "fdokty54"; //Enter the password to your user
$db = "knaldhat"; //Enter the database on your MySQL server where you created the table from the structure.sql

//Do not modify anything under this line!

//Get the input typed in the form
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];
$time = date("d/m-Y H:i:s");

//If nothing was typed in the name field, then the Name will be replaced with 'anonymous'
if ($_POST['name'] == "Name") {
    $name = "Anonymous";
}

//If nothing was typed in the E-mail field, then the E-mail will be replaced with null@null
if ($_POST['email'] == "E-mail") {
    $email = "null@null";
}

//Connect to the MySQL server
mysql_connect("$host", "$user", "$pass");

//Select a database
mysql_select_db($db);

//If the text field isn't empty, then this code will be executed:
//If an URL was typed in the text field, then it will be replaced with <a

href='http://somedomain.com'>http://somedomain.com</a>
//If an < or > has been typed, it will be replaced with &lt; or &gt;
//Insert the data into the MySQL database
if(!empty($_POST['text'])){
    $text = ereg_replace("<", "&lt;", $text);
    $text = ereg_replace(">", "&gt;", $text);
    $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $text);
    $text = str_replace($emotearr, $emotepath, $text);

    $insertSQL = "insert into tagwall (name, email, time, text) values ('$name', '$email', '$time', '$text')";
    mysql_query($insertSQL);
}

//Get all the data from the MySQL database, sort by the row 'id' and limit the rows that's being printed to 20
//Make an array from the $result variable
//Convert the 'new line's to <br>
$result = mysql_query("SELECT * FROM tagwall ORDER BY id DESC LIMIT 20") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
    echo "<font family='Trebuchet MS, sans-serif' size='2'><b><a href='mailto:%22.$row[' email']."'>".$row['name']."</a></b>

- ".$row['time']."<br>";
    echo nl2br($row['text']);
    echo "<br><br>";
}

//Close the connection to the MySQL server
mysql_close();
?>

<br><br>

</body>
</html>
Avatar billede spunk13 Nybegynder
25. januar 2004 - 13:47 #11
echo "<img src='".$emotepath[$i]."' onClick='indsaetSmiley(\'".$emotearr[$i]."\');'>&nbsp; ";
Avatar billede spunk13 Nybegynder
25. januar 2004 - 13:48 #12
hovsa..

Denne linje
echo "<img src='".$emotepath[$i]."' onClick=''indsaetSmiley(\'".$emotearr[$i]."\');'>&nbsp; ";
skal erstattes med
echo "<img src='".$emotepath[$i]."' onClick='indsaetSmiley(\'".$emotearr[$i]."\');'>&nbsp; ";
Avatar billede spunk13 Nybegynder
25. januar 2004 - 14:02 #13
Glem det, det virker ikke alligevel, kigger lige på det igen når jeg får tid.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester