Erstat :D Med smiley-billede
Hej i eksperter...Jeg har et bruger system,hvor vær bruger har vær deres gæstebog...Nu vil jeg så gerne tilføje en funktion som erstatter :D med et smiley-billede...Ved godt det skal kodes med str_replace,men jeg ved ikke hvordan det skal gøres...Og så kommer mit andet spørgsmål,Hvordan kan jeg lave en funktion,hvor brugeren kan slette de beskeder som bruger har fået fra andre brugere?Database taqwall:
CREATE TABLE `taqwall` (
`id` int(11) NOT NULL auto_increment,
`til` varchar(255) NOT NULL default '',
`fra` varchar(255) NOT NULL default '',
`besked` varchar(255) NOT NULL default '',
`dato` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
Koden til gæstebogen:
<?php
include("menu.php");
?>
<?php
include_once("connect.php");
$db_profil = mysql_query("select * from brugere where brugernavn = '$_GET[b]'");
$profil = mysql_fetch_array($db_profil);
if($_GET['admin'] == "1"){
if($_SESSION['Rang'] == "Admin"){
mysql_query("UPDATE brugere SET status= '". mktime() ."' WHERE brugernavn = '$_SESSION[brugernavn]'");
mysql_query("UPDATE brugere SET Rang = 'Admin' where id = '$_GET[bruger]'");
print "Brugeren blev gjort til admin!";
}
}
?>
<html>
<head>
<title>Profil</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="http://www.mvf.frac.dk/sty1e2.css" type="text/css" />
<style type="text/css">
<!--
.style3 {font-size: large}
-->
</style>
</head>
<body>
<table width="100%" border="0">
<tr>
<td width="253" height="164" valign="top"><?php if($profil['billede'] != ""){ ?>
<a href="<?php print $profil['billede'] ?>"><img src="<?php print $profil['billede'] ?>" width="100" height="100" border="0"></a>
<?php }else{ ?>(Intet billede!)<?php } ?></td>
<td width="732" valign="top"><div align="left">
<table width="100%" border="0">
<tr>
<td width="14%">Brugernavn: </td>
<td width="28%"><?php print $profil['brugernavn'] ?></td>
<td width="58%"><span class="style3">Point: <?php print $profil['point'] ?> </span></td>
</tr>
<tr>
<td>Navn:</td>
<td><?php print $profil['navn'] ?></td>
<td> </td>
</tr>
<tr>
<td>Køn:</td>
<td><?php print $profil['kon'] ?></td>
<td> </td>
</tr>
<tr>
<td>Civilstatus</td>
<td><?php print $profil['civilstatus'] ?></td>
<td> </td>
</tr>
<tr>
<td>Alder:</td>
<td><?php print $profil['alder'] ?> år.</td>
<td> </td>
</tr>
<tr>
<td>Fritid:</td>
<td><?php print $profil['fritid'] ?></td>
<td> </td>
</tr>
<tr>
<td>Landsdel:</td>
<td><?php print $profil['landsdel'] ?></td>
<td>Status:<?php
session_start();
include_once("connect.php");
$online = mysql_query("SELECT * FROM brugere WHERE brugernavn = '[brugernavn]'");
while($row = mysql_fetch_array($online))
{
print "Denne profil er:";
if($row['status']>mktime(-300))
{
print "Online";
}
else
{
print "Offline";
}
}
?>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table width="100%" height="154" border="1">
<tr>
<td height="111" valign="top"><?php print $profil['navn'] ?>´s Profil: </td>
</tr>
<tr>
<td valign="top"><a href="http://mwf.frac.dk/community/redigerProfil.php"></a></td>
</tr>
</table>
<br>
<p><strong>Gæstebog:</strong></p>
<table width="400" border="0">
<?php
$q2 = mysql_query("select * from taqwall where til = '$profil[id]'");
while($taqwall = mysql_fetch_array($q2)){
$q3 = mysql_query("DELETE FROM taqwall WHERE id = '$_GET[besked]'");
?>
<tr>
<td width="195" bgcolor="#4D73C3"> </td>
<td width="195" bgcolor="#4D73C3">Dato: <?php print $taqwall['dato'] ?></td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" bgcolor="#FFFFFF">Brugernavn: <?php print $taqwall['fra'] ?></td>
</tr>
<tr bgcolor="#CCCCCC">
<th colspan="2" bgcolor="#FFFFFF"><?php print $taqwall['besked'] ?> th>
</tr>
<?php
}
?>
</table>
<p> <a href="taqwall.php?do=skriv&id=<?php print $profil['id'] ?>&bruger=<?php print $profil['brugernavn'] ?>">Skriv
i denne gæstebog! </a></p>
<?php
if($profil['brugernavn'] == $_SESSION['Brugernavn']){
?>
<p><a href="editprofil.php?id=<?php print $profil['id'] ?>">Ret profil!</a></p>
<?php
}
?>
</body>
</html>
