smilies in mySQL

Kimble

Erfahrenes Mitglied
hi,
wie kann ich :) - also : ) - abfangen und das durch eine Grafik erstezn. Also nicht, wie bei dem GB weiter unten.
Soll in mySQL sein.

Hier mein Code:
PHP:
<html>
<head><title>show-news</title>
<!-- CSS Begin		//-->
<style type="text/css">
<!--
	table { font-family: helvetica, arial, geneva, sans-serif; font-size: 10pt; background:  #FFFFFF; }
	td.left { font-family: helvetica, arial, geneva, sans-serif; font-size: 10pt; background: #CCCCCC; word-break: break-all; word-wrap: break-word; }
	td.right { font-family: helvetica, arial, geneva, sans-serif; font-size: 10pt; background: #DDDDDD; word-break: break-all; word-wrap: break-word; }
	td.edit { font-family: helvetica, arial, geneva, sans-serif; font-size: 10pt; background: #CCCCCC; word-break: break-all; word-wrap: break-word; }
//-->
</style>
<!-- CSS End		//-->
<!-- Show NEWS PHP  Begin //-->
<?php
	# include aller wichtigen Dateien
	include "includes/mysql.connect.inc";
	include "includes/mysql.close.inc";

	# zu Datenbank connecten
	# host, user, pw, db
	sqlconnect( "localhost", "xxx", "xxx", "clan" );

	$res = mysql_db_query( "clan", "SELECT * FROM news" );
	$num = mysql_num_rows( $res );

	if( $num == 0 )
	{
		echo "No news in database!";
	}

	for( $i=0; $i<$num; $i++ )
	{
		$cb = mysql_result( $res, $i, "createdby" );
		$tc = mysql_result( $res, $i, "topic" );
		$in = mysql_result( $res, $i, "inhalt" );
		$dt = mysql_result( $res, $i, "date" );
		$ti = mysql_result( $res, $i, "time" );
		$co = mysql_result( $res, $i, "comments" );

		// echo "$cb, $tc, $in, $dt, $ti, $co";
		echo "<table border=\"0\" width=\"570\">";
		echo "<tr><td align=\"left\" class=\"left\" width=\"100\">&nbsp;Creator:</td>"
			 . "<td align=\"left\" class=\"right\">&nbsp;$cb</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"50\">Edit</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"60\">Delete</td></tr>";

		echo "<tr><td align=\"left\" class=\"left\" width=\"100\">&nbsp;Date:</td>"
			 . "<td align=\"left\" class=\"right\">&nbsp;$dt</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"50\">Edit</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"60\">Delete</td></tr>";

		echo "<tr><td align=\"left\" class=\"left\" width=\"100\">&nbsp;Time:</td>"
			 . "<td align=\"left\" class=\"right\">&nbsp;$ti</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"50\">Edit</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"60\">Delete</td></tr>";

		echo "<tr><td align=\"left\" class=\"left\" width=\"100\">&nbsp;Comments:</td>"
			 . "<td align=\"left\" class=\"right\">&nbsp;$co</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"50\">Edit</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"60\">Delete</td></tr>";

		echo "<tr><td align=\"left\" class=\"left\" width=\"100\">&nbsp;Topic:</td>"
			 . "<td align=\"left\" class=\"right\">&nbsp;$tc</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"50\">Edit</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"60\">Delete</td></tr>";

		echo "<tr><td align=\"left\" class=\"left\" width=\"100\">&nbsp;Content:</td>"
			 . "<td align=\"left\" class=\"right\">&nbsp;$in</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"50\">Edit</td>"
			 . "<td align=\"center\" class=\"edit\" width=\"60\">Delete</td></tr>";

		echo "</table><br>";
	}

	# Datenbank schliessen
	sqlclose( );
?>
<!-- Show NEWS PHP End	  //-->
</head>

<body bgcolor="#ffffff">

</body>
</html>

Hat jemand sowas schonmal gemacht???
Bitte helft!
 
Zuletzt bearbeitet:
teile eines strings ersetzten kannst du mit str_replace

wenn du die smilies aus mysql 'ziehen' willst, brauchst du ja nur eine tabelle mit pattern und dem string, der pattern ersetzen soll.

das musst du dann in ne schleife bauen.
 
aehm, sry
bin noch relativ neu in mySQL.
Was meinst du jetzt mit Pattern???

hab das so probiert:
PHP:
str_replace(": )","<img src=\"pfad/zum/smilie.gif\" border=\"0\">",$in);

Kannst du mir en Beispiel sagen :)
 
Zuletzt bearbeitet:
ok,
hat sich erledigt:
PHP:
$in = str_replace( ": )", "<img src=\"images/smile.gif\" border=\"0\">", $in );
 
Zurück