Jump to content

[SOLVED] Make icon appear with comments


djfox

Recommended Posts

Ok, I have this system setup where for a submission put on the server, registered users can comment on it. I`ve tried repeatedly trying to get the thing to display icons from userdata with each comment. I`ll let my code speak for itself. These two sections of code I`m displaying are from the file trances.php. I`m not displaying each every piece of the code because I feel most of it is not necessary to show because they are unrelated to the problem.

 

<?
$lev=$_SESSION['level2'];

$res = mysql_query("SELECT id,name,gallNum,URL,rating,numRates,description,views,cat,addDate, feature, literature, favnum, nomi, keyw FROM image WHERE id=$id");
$rows = mysql_fetch_row($res);
mysql_free_result($res);

if($submit){
   $s = $sub." by ".$name;
   $b= emote($bod);
   mysql_query("INSERT INTO comment (imageID,subject,content,date,sender) VALUES ( '$id', '$s', '$b', NOW(),$send)")or die ( mysql_error());
   $_SESSION['echos'] = $echos = $echos + 10;
   mysql_query("UPDATE userdata SET echo_count = $echos WHERE login = '".$log."' ") or die(mysql_error());
   mysql_query("INSERT INTO messagedata (recBoxID, sendBoxID, content, subject, isNew, date) VALUES ($rows[2], '1', 'You have a new comment on one of your trances that you have submitted.<br><a href=trances.php?id=$id>Click here to read the comment</a>.<br>This is automated message please do not reply.', 'New Comment!', 1, NOW() )");

}
if($policy && ($lev>6)){
   mysql_query("UPDATE userdata SET violations=SUM(violations,1) WHERE login='$name'");
}

$res = mysql_query("SELECT login FROM userdata WHERE id='$rows[2]'");
$by = mysql_fetch_row($res);
mysql_free_result($res);

$res = mysql_query("SELECT icon FROM userdata WHERE id='$rows[2]'");
$icon = mysql_fetch_row($res);
mysql_free_result($res);

$res = mysql_query("SELECT name, id FROM imagecats WHERE id=$rows[8]");
$catName = mysql_fetch_row($res);
mysql_free_result($res);

$res = mysql_query("SELECT COUNT(*) FROM comment WHERE imageID='$id'");
$numCom = mysql_fetch_row($res);
mysql_free_result($res);

//Update unique pageview counter
if( !$_SESSION["sess_$id"] ){
   $_SESSION["sess_$id"] = "visited";
   $v = $rows[7] + 1;
   mysql_query("UPDATE image SET views=$v WHERE id='$id'");
}
?>

 

And in the same file we have:

 

<?
$res = mysql_query("SELECT subject,content,date,id,sender FROM comment WHERE imageID=$id ORDER BY id DESC");
while($r = mysql_fetch_row($res) ) $comments[] = $r;

if ($comments) foreach($comments as $c){
?>
<table border=0 width=100%>
<tr>
<td>
<tr>
<td>
<table border=0 width=100% bgcolor="000000">
<tr><td bgcolor="312D37" colspan=2><a href="trancer.php?g=<? echo $c[4] ?>"><? echo $c[0] ?></a>       Date: <? echo $c[2] ?>       #<a href="comment.php?id=<? echo $c[3] ?>"><? echo $c[3] ?></a>
<tr><td colspan=2 bgcolor="4A4553"><? echo $c[1] ?>
</table>
</table>
<?
}
?>

 

sender has the id number of the person who makes the comment. Clicking on their name will take you to their profile.

 

What I`m looking for is that the icon from userdata will appear with the person. userdata id should equal to sender from comment

 

How is this accomplished? I`m totally stumped.

Link to comment
Share on other sites

I figured out how to do it. I feel really stupid since it was just so simple any easy to do. The code ended up being:

 

<?
$res = mysql_query("SELECT subject,content,date,id,sender FROM comment WHERE imageID=$id ORDER BY id DESC");
while($r = mysql_fetch_row($res) ) $comments[] = $r;

if ($comments) foreach($comments as $c){
?>
<?
$res = mysql_query("SELECT id, icon FROM userdata WHERE id='$c[4]'");
$comico = mysql_fetch_row($res);
mysql_free_result($res);
?>
<table border=0 width=100%>
<tr>
<td>
<tr>
<td>
<table border=0 width=100% bgcolor="000000">
<tr><td bgcolor="312D37" colspan=2><img src="<? echo "$comico[1]" ?>"><a href="trancer.php?g=<? echo $c[4] ?>"><? echo $c[0] ?></a>       Date: <? echo $c[2] ?>       #<a href="comment.php?id=<? echo $c[3] ?>"><? echo $c[3] ?></a>
<tr><td colspan=2 bgcolor="4A4553"><? echo $c[1] ?>
</table>
</table>
<?
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.