Въпрос за аватар

chaser

Registered
както се добовят коментарите при тяхното за писване да записва и аватара на потребителя който го е добавил как ще стане
ето и кода за добавяне

PHP:
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="content-type" content="text/html;  charset=window-1251" />
      <title>Добави коментар</title>
	   <script> 
      subdomain_ad_social_hide_facebook = "1";
      subdomain_ad_social_hide_twitter  = "1";
     </script> 
	  <script src="BBbutons.js"  type="text/javascript"></script> 
	  </head>
	  <body style="background: #ececec;">
<div align="center">	  
	  <form method="post">
	  <script>bbcodetoolbar('area'); </script> 
	  <textarea id="area" name="comment" cols="40" rows="12"></textarea><br />
	  <input type="submit" name="submit" value="Прегледай"/>
	  <input type="hidden" name="post" value="<?php echo $_GET['post'];?>"/>
	  <input type='submit' name='addComment' value='Коментирай' />
	  </form>	
</div>	  
	  <br />
		
	  <?php  
	  include "config.php";
	  if(isset($_POST['submit'])) {
	  include "bbcode.php";
	  echo bbcode($_POST['comment']);
	  
	  }
	  ?>
	  <?php
if(isset($_POST['addComment']))
{
 $post_id = $_POST['post'];
 $comment = $_POST['comment'];
 $author = $_SESSION["my_ime"];
 $date = date("d.m.Y,G:i ч.");


$comment = str_replace(":)","<img border=0 src='http://localhost/bbcodes/smiles/smile.gif' alt='images'/>", $comment);
$comment = str_replace(":D","<img border=0 src='http://localhost/bbcodes/smiles/laught.gif' alt='images'/>", $comment);
$comment = str_replace(":linkoslove:","<img border=0 src='http://localhost/Maxell.bg/comment/images/smilie/linkoslove.gif' alt='images'/>", $comment);
$comment = str_replace(":-)","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/smile1.gif alt='images'/>", $comment);
$comment = str_replace(";-)","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/wink.gif alt='images'/>", $comment); 
$comment = str_replace(":-D","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/grin.gif alt='images'/>", $comment); 
$comment = str_replace(":-P","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/tongue.gif alt='images'/>", $comment); 
$comment = str_replace(":-(","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/sad.gif alt='images'/>", $comment); 
$comment = str_replace(":-|","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/noexpression.gif alt='images'/>", $comment);
$comment = str_replace(":-/","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/confused.gif alt='images'/>", $comment); 
$comment = str_replace(":-O","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/ohmy.gif alt='images'/>", $comment); 
$comment = str_replace(":o)","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/clown.gif alt='images'/>", $comment);
$comment = str_replace("8-)","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/cool1.gif alt='images'/> ", $comment);
$comment = str_replace("|-)","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/sleeping.gif alt='images'/>", $comment);
$comment = str_replace(":innocent","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/innocent.gif alt='images'/> ", $comment);
$comment = str_replace(":whistle:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/whistle.gif alt='images'/> ", $comment);
$comment = str_replace(":unsure:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/unsure.gif alt='images'/>", $comment);
$comment = str_replace(":closedeyes:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/closedeyes.gif alt='images'/> ", $comment);
$comment = str_replace(":angry:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/angry.gif alt='images'/>", $comment);
$comment = str_replace(":smile:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/smile2.gif alt='images'/>", $comment);
$comment = str_replace(":lol:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/laugh.gif alt='images'/> ", $comment);
$comment = str_replace(":cool:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/cool2.gif alt='images'/> ", $comment);
$comment = str_replace(":fun:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/fun.gif alt='images'/> ", $comment);
$comment = str_replace(":thumbsup:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/thumbsup.gif alt='images'/> ", $comment);
$comment = str_replace(":thumbsdown:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/thumbsdown.gif alt='images'/> ", $comment);
$comment = str_replace(":blush:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/blush.gif alt='images'/>", $comment);
$comment = str_replace(":weep:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/weep.gif alt='images'/> ", $comment);
$comment = str_replace(":yes:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/yes.gif alt='images'/> ", $comment);
$comment = str_replace(":no:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/no.gif alt='images'/> ", $comment);
$comment = str_replace(":?:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/question.gif alt='images'/> ", $comment);
$comment = str_replace(":!:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/excl.gif alt='images'/> ", $comment);
$comment = str_replace(":idea:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/idea.gif alt='images'/> ", $comment);
$comment = str_replace(":arrow:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/arrow.gif alt='images'/> ", $comment);
$comment = str_replace(":hmm:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/hmm.gif alt='images'/>", $comment);
$comment = str_replace(":hmmm:","<img border=0 src=http://localhost/Maxell.bg/comment/images/smilie/hmmm.gif alt='images'/>", $comment);


 $comment = addslashes(htmlspecialchars($comment));
 mysql_query("INSERT INTO comments(post_id, comment, author,date) VALUE ('$post_id','$comment','$author','$date')"); 
 
}

?>

	  </body>
	  </html>
 
дори да си смини аватара то коментарите на аватара на потребителя ще си смени това за мен няма значение

ако имаш по добра идия за изваждането на коментарите покажими я
 
PHP:
<?php
$query = mysql_query("SELECT * FROM `users` WHERE `username`= $author") or die (mysql_error());
while($row = mysql_fetch_assoc($query)){
$avatar = $row['avatar'];
}
?>
<img src='<? echo $avatar; ?>'/>
 
Това, което искаш е много глупаво. Просто си правиш колона за аватар в таблицата за потребители, и ползваш горния код.
 

Back
Горе