TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

July 03, 2024, 06:59:20 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,285
  • Total Topics: 21,228
  • Online today: 46
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 55
  • Total: 56
  • @rjen

[BLOCK] Unanswered Topics Block

Started by shengton, September 26, 2008, 09:26:11 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JPDeni


shengton

Thanks Maam, it works.

Updated the code.

Here's the output:


FERNSIDEâ„¢

Hi SHENGTON,
for people such as myself that cannot tie their own shoelaces without a step by step manual :uglystupid2:, could you possibly publish your final code here please?

Thank You  :)

alhaudhie

#23
Quote from: SHENGTON on October 02, 2008, 06:59:03 AM
Perfect...This is what I need...Yehey..Thanks guys. You're great programmers.

global $db_prefix, $scripturl, $user_info, $modSettings;

$number_to_display = 5; // Change this if you want a different number to display. Use 0 to list all of them.
$most_recent_first = 0; // If you want to display the oldest first, change this to 0

if(!empty($modSettings['recycle_enable'])) $recycle_board = $modSettings['recycle_board'];

//////////////////////////////////////////

($most_recent_first == 1) ? $order = 'DESC' : $order = 'ASC';
($number_to_display == 0) ? $limit = '' : $limit = "LIMIT " . $number_to_display;

$query = db_query(
"SELECT m.subject, t.ID_TOPIC
FROM {$db_prefix}topics as t, {$db_prefix}messages as m, {$db_prefix}boards AS b
WHERE t.numReplies = 0
AND t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_BOARD = b.ID_BOARD
AND $user_info[query_see_board]
AND b.ID_BOARD != $recycle_board
AND m.subject NOT LIKE '%MOVED:%'
ORDER BY t.ID_FIRST_MSG " . $order . ' ' .
$limit, __FILE__, __LINE__);

echo '';
while ($row = mysql_fetch_assoc($query))
  echo '<img src="image url"> <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">' . $row['subject'] . ' <img src="image url"></a>';
echo '</ul>';


with this code above i have this result in my block

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND m.subject NOT LIKE '%MOVED:%'
ORDER BY t.ID_FIRST_MSG ASC LIMIT 5' at line 8
File: /home/mysite/public_html/v0/Sources/Load.php(1999) : eval()'d code(52) : eval()'d code
Line: 23

JPDeni

Do you have a recycle board ... one that all deleted posts are immediately transferred to? If not, remove


AND b.ID_BOARD != $recycle_board

JPDeni

I think this may be a better way to go with the code:


global $db_prefix, $scripturl, $user_info, $modSettings;

$number_to_display = 5; // Change this if you want a different number to display. Use 0 to list all of them.
$most_recent_first = 0; // If you want to display the oldest first, change this to 0

if(!empty($modSettings['recycle_enable'])) $recycle_board = $modSettings['recycle_board'];
else $recycle_board = 0;

//////////////////////////////////////////

($most_recent_first == 1) ? $order = 'DESC' : $order = 'ASC';
($number_to_display == 0) ? $limit = '' : $limit = "LIMIT " . $number_to_display;

$query = db_query(
"SELECT m.subject, t.ID_TOPIC
FROM {$db_prefix}topics as t, {$db_prefix}messages as m, {$db_prefix}boards AS b
WHERE t.numReplies = 0
AND t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_BOARD = b.ID_BOARD
AND $user_info[query_see_board]
AND b.ID_BOARD != $recycle_board
AND m.subject NOT LIKE '%MOVED:%'
ORDER BY t.ID_FIRST_MSG " . $order . ' ' .
$limit, __FILE__, __LINE__);

echo '<ul>';
while ($row = mysql_fetch_assoc($query))
  echo '<li><a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">' . $row['subject'] . '</a></li>';
echo '</ul>';


This should make it work whether you have a recycle board set or not.

alhaudhie


JPDeni

Just a random post? There's code here to pull in a random post. If you want to make a random unanswered post, change


ORDER BY t.ID_FIRST_MSG " . $order . ' ' .


to


ORDER BY RAND()


and set the $number_to_display variable to 1.

alhaudhie

Having this after replace with

ORDER BY RAND()

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/myhome/public_html/v0/Sources/Load.php(1999) : eval()'d code(52) : eval()'d code on line 28

where is the variable setting must set up wih 1?

alhaudhie

Quote from: JPDeni on November 12, 2008, 02:28:19 PM
I'm so glad that you can access it. Other team members can, too, but for some reason I can't.

Okay. Here's the correct answer. Change


ORDER BY t.ID_FIRST_MSG " . $order . ' ' .
$limit, __FILE__, __LINE__);


to


ORDER BY RAND() " .
$limit, __FILE__, __LINE__);


That should give you what you want. I'm sorry I got it wrong before.


I hope this gets worked out soon.

Take care.

JPDeni

Thanks.. good working now...