Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 6th, 2012  |  syntax: None  |  size: 2.43 KB  |  views: 52  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Guys!
  2. I'm asking any interesting people who may help to integrate the latest comments natively to udjacomments,
  3. but for now i want to bring you a straight solution which just works. Whole part of this code belongs to MrWheeli, ukrainian blogger and web-developer.
  4.  
  5. Source article here: http://www.mrweevil.com/index.php/phpmysql/21-vyvodymo-ostanni-komentari-na-udja-comments
  6. So, as udja stores its comments in database, we can write php code to extract them and display somewhere on the site. This code you need to insert in Custom html module page and choose where to display it, and you got it!
  7.  
  8. [code]
  9. <?
  10. $db = mysql_connect ("server address",bd_username","bd_userpassword");
  11. mysql_select_db ("bd_name");
  12. mysql_query("SET NAMES utf8");
  13. $result_udja
  14.  = mysql_query ("SELECT id,full_name,content,comment_url FROM
  15. i8ntl_udjacomments WHERE is_published='1' ORDER BY time_added DESC, id
  16. DESC LIMIT 5");
  17.        
  18.         if (!$result_udja)
  19.         {
  20.            
  21.  echo "<p>Opps, error!<br>Report to administrator e-mail<br>Error:</p>";
  22.             exit (mysql_error());
  23.         }
  24.         if (mysql_num_rows($result_udja) > 0)
  25.         {
  26.         $myrow_udja = mysql_fetch_array ($result_udja);
  27.                
  28.        
  29.         echo "<br><p class='last_title'>Last comments: </p>";
  30.              
  31.         do
  32.         {
  33.         $text = $myrow_udja ['content'];
  34.         $text = substr ($text,0,200);
  35.         $url_link = $myrow_udja ['comment_url'];
  36.         $url_link = substr ($url_link,12,3);
  37.        
  38.        $result_udja1 = mysql_query ("SELECT id,alias,catid FROM i8ntl_content WHERE id='$url_link'");
  39.        $myrow_udja1 = mysql_fetch_array ($result_udja1);
  40.        $id = $myrow_udja1 ['id'];
  41.        $catid = $myrow_udja1 ['catid'];
  42.        $alias = $myrow_udja1 ['alias'];
  43.        
  44.        $result_udja2 = mysql_query ("SELECT alias FROM i8ntl_categories WHERE id='$catid'");
  45.        $myrow_udja2 = mysql_fetch_array ($result_udja2);
  46.        $catalias = $myrow_udja2 ['alias'];
  47.        
  48.        
  49.  printf ("<p class='last_auth'><a
  50. href='http://yoursite.com/index.php/%s/%s-%s'>%s</a></p><p
  51.  class='last_comment'>%s</p>", $catalias, $id, $alias,
  52. $myrow_udja["full_name"], $text);
  53.        
  54.         }
  55.         while ($myrow_udja = mysql_fetch_array($result_udja));
  56.         }
  57.         else
  58.         {
  59.             echo "<p>No data to fulfill your request!</p>";
  60.             exit();
  61.         }          
  62.                    
  63.  ?>      
  64. [/code]
clone this paste RAW Paste Data