[-_-] Posted December 2, 2008 Share Posted December 2, 2008 I know how to do the javascript to make clickable smileys that insert anscii smileys into the form. But I have no idea of how to make it show up in php or if I need to add anything to the mySQL database? Could anyone help me figure this out? I think this might be the code which manages the images in the comment script. // construct page query to find out how many matches $query = "SELECT * from $db_table WHERE page_id = '$page_id' AND is_approved = '1' ORDER by dated DESC LIMIT $from, $comment_limit";// what matches THIS page? $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // skip output if no comments exist if (!$count) { echo "<center><p style='". $num_style. "'>". $no_comments. "</p></center>"; } else { echo "<center><p style='". $num_style. "'>". $comments_to_date. $count. $this_is_page. $comm_page. $page_of_page. $total_pages. ". "; if (($av_rating>0) && ($art_rating==1)) { $stars = 5 * round($av_rating/0.5); echo $average_rating. "<img src='comments/images/stars/stars_". $stars. ".png' alt=''/></center>"; } echo "</p>"; // output comments echo "<table cellpadding='0' cellspacing='0' width='100%' border='0' align='center'>"; while ($myrow = mysql_fetch_array($result)) // loop through all results { $style = $style == $ro1 ? $ro2 : $ro1; echo "<tr bgcolor='". $style. "'>"; echo "<td><p style='". $comm_style. "'><b>"; if ($show_flags == 1) { $flag_image = "comments/images/flags/". $myrow['flag']. ".png"; if (file_exists($flag_image)) { $size = getimagesize($flag_image); echo " <img src='". $flag_image. "' ". $size[3]. " alt=''/> "; } if (!$myrow['name']) { echo $unknown_poster; } else { echo $myrow['name']; } } echo "</b></p></td>"; echo "<td align='right'><p style='". $commdate_style. "'>"; niceday($myrow['dated']); echo "<br/>"; if (($art_rating==1) && ($myrow['rating']>0) && ($visitor_rating==1)) { $star_img = "comments/images/stars/stars_". 10*$myrow['rating']. ".png"; $size = getimagesize($star_img); echo " <img src='". $star_img. "' ". $size[3]. " alt=''/>"; } echo "</p></td></tr>"; echo "<tr bgcolor='". $style. "'>"; echo "<td colspan='2' style='border-bottom:1px dotted ". $space_color. ";'> <p style='". $comm_style. "'> "; $comments = stripslashes($myrow['comments']); if (strlen($comments)>$maxshow_comments) { $comments = substr($comments,0,$maxshow_comments). "... <a href='comments/showmore.php?id=". $myrow['id']. "'>". $show_more. "</a> <strong>»</strong>"; } echo nl2br($comments); if ($myrow['admin_comment']) { echo "<br/><br/>". $admin_comment. " <span style='color:#c30;'><em>". $myrow['admin_comment']. "</span></em>"; } echo "</p></td></tr>\n"; } // loop done echo "</table>\n"; } // Pagination magic (of sorts) And heres the mySQL thing I have to import into phpmyadmin when I first setup the script. # # Table structure for table `page_comments` # CREATE TABLE IF NOT EXISTS page_comments ( id mediumint(11) NOT NULL auto_increment, name varchar(40) NOT NULL default '', location varchar(40) NOT NULL default '', flag varchar(20) NOT NULL default '', comments text NOT NULL, ip varchar(20) NOT NULL default '', page_id varchar(40) NOT NULL default '0', dated datetime NOT NULL default '0000-00-00 00:00:00', rating tinyint(1) NOT NULL default '0', admin_comment text NOT NULL default '', is_approved tinyint(1) NOT NULL default '1', PRIMARY KEY (id) ) TYPE=MyISAM AUTO_INCREMENT=1 ; Quote Link to comment Share on other sites More sharing options...
nitation Posted December 2, 2008 Share Posted December 2, 2008 javascript can certainly do this for you. Quote Link to comment Share on other sites More sharing options...
[-_-] Posted December 2, 2008 Author Share Posted December 2, 2008 javascript can certainly do this for you. Yes but dont I need it stored in the database? and I need to do something to the php to make it show up once the comment is posted. Quote Link to comment Share on other sites More sharing options...
[-_-] Posted December 3, 2008 Author Share Posted December 3, 2008 Someone told me that the code at the bottom might work, I tried putting this in under # $comments = stripslashes($myrow['comments']); # if (strlen($comments)>$maxshow_comments) { But it wont work. str_replace("", "<img src='http://www.plentyoftorrents.com/flsh/smileys/hai_gais.gif' alt='' />", $comments); This is the page where Im trying to test it out. http://www.plentyoftorrents.com/flsh/animation/princess-1 Does anyone know whats going wrong there? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.