SMFHacks.com
** Home Forum Index Hacks Products Login Register Search
Welcome, Guest. Please login or register.
May 25, 2012, 04:32:03 am

Login with username, password and session length
Members
Total Members: 10071
Latest: cdavidson012
Stats
Total Posts: 28687
Total Topics: 4977
Online Today: 59
Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Users: 0
Guests: 60
Total: 60
+ 
|-+ 
| |-+ 
| | |-+ 
| | | |-+ 
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: Recent Comments in a portal block  (Read 993 times)
cosmicx
Full Member
***
Offline Offline

Posts: 107


View Profile
« on: September 01, 2011, 09:41:54 am »

how to accomplish this? i have adkportal in my dev site
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 9678


View Profile
« Reply #1 on: September 02, 2011, 08:58:47 am »

Would need to write a query to get all recent comments from listings that are not removed and then have it displayed it would be php code.
Logged
cosmicx
Full Member
***
Offline Offline

Posts: 107


View Profile
« Reply #2 on: September 03, 2011, 05:04:14 am »

i have no idea how to do that? any instructions in English? don't know sql and php.
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 9678


View Profile
« Reply #3 on: September 06, 2011, 07:03:02 pm »

Example code:
Code:
global $smcFunc;
  $dbresult = $smcFunc['db_query']('', "
  SELECT
  c.ID_COMMENT, c.ID_LISTING, c.comment, c.date, c.ID_MEMBER, m.member_name,
  m.real_name FROM {db_prefix}class_comment as c
  LEFT JOIN {db_prefix}members AS m ON (c.ID_MEMBER = m.ID_MEMBER)
  WHERE c.approved = 1 ORDER BY c.ID_COMMENT DESC LIMIT 10");
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{

echo '<a href="' . $scripturl . '?action=classifieds;sa=view;id=' . $row['ID_LISTING'] . '">' . substr($row['comment'], 0, 100)  .'</a><br />
by ';

if($row['real_name'] != '')
echo '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">'  . $row['real_name'] . '</a>';
else
echo ''  . $txt['class_guest']. '';
echo '<br />
', timeformat($row['date']), '
<hr /><br />';


}
Logged
cosmicx
Full Member
***
Offline Offline

Posts: 107


View Profile
« Reply #4 on: September 07, 2011, 04:17:00 am »

thank you for the respond....


i've tried the code, it only displays the comment and the one who give the comment and the date. In the original  comment block, it shows the Category and the Listing title.

In my case, I only want to display the Listings title. I hope you may help me further.
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 9678


View Profile
« Reply #5 on: September 07, 2011, 08:00:28 am »

Try
Code:
<?php

global $smcFunc;
   $dbresult $smcFunc['db_query'](''"
   SELECT 
   c.ID_COMMENT, c.ID_LISTING, c.comment, c.date, c.ID_MEMBER, l.title
    FROM {db_prefix}class_comment as c, {db_prefix}class_listing as l

   WHERE l.ID_LISTING = c.ID_LISTING AND c.approved = 1 ORDER BY c.ID_COMMENT DESC LIMIT 10"
);
while($row $smcFunc['db_fetch_assoc']($dbresult))
{

echo '<a href="' $scripturl '?action=classifieds;sa=view;id=' $row['ID_LISTING'] . '">' substr($row['title'], 0100)  .'</a><br />';


}
Logged
cosmicx
Full Member
***
Offline Offline

Posts: 107


View Profile
« Reply #6 on: September 08, 2011, 09:31:23 pm »

thank you so much for this.... more power smfhacks..
Logged
cosmicx
Full Member
***
Offline Offline

Posts: 107


View Profile
« Reply #7 on: September 25, 2011, 11:35:12 am »

hello again... i've been struggling to put this code in a 2 row table.


what i want to accomplish is... display 20 recent comments... 10 in each row... im just learning about basic tables right now.

i don't know yet, how to incorporate it with php and sql. i hope you may help.
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  

Recent
[May 24, 2012, 08:02:50 am]

[May 24, 2012, 04:11:41 am]

[May 21, 2012, 08:54:11 am]

[May 20, 2012, 11:06:52 am]

[May 20, 2012, 05:58:11 am]

[May 19, 2012, 06:16:58 pm]

[May 19, 2012, 05:42:37 pm]

[May 18, 2012, 03:08:38 pm]

[May 17, 2012, 06:07:46 pm]

[May 17, 2012, 02:22:07 pm]
Random Picture
Donate to SMFHacks.com
Help Support the SMFHacks.com mod making.
Powered by SMF 1.1.16 | SMF © 2006-2011, Simple Machines LLC
TinyPortal v0.9.7 © Bloc
SMF and SimpleMachines are registered trademarks of Simple Machines. SMFHacks.com is not affiliated with nor endorsed by Simple Machines.
Page created in 0.231 seconds with 18 queries.