dopetalk does not endorse any advertised product nor does it accept any liability for it's use or misuse


Our Discord Notification Server invitation link is https://discord.gg/jB2qmRrxyD

Author Topic: Batch job: "listall_topicsandboards.php"  (Read 7 times)

Online Chip (OP)

  • Server Admin
  • Hero Member
  • *****
  • Administrator
  • *****
  • Join Date: Dec 2014
  • Location: Australia
  • Posts: 7149
  • Reputation Power: 0
  • Chip has hidden their reputation power
  • Gender: Male
  • Last Login:Today at 02:42:17 AM
  • Deeply Confused Learner
  • Profession: IT Engineer now retired
Batch job: "listall_topicsandboards.php"
« on: Yesterday at 11:24:50 PM »
<?php

// Load SMF bootstrap
require_once(dirname(__FILE__) . '/SSI.php');

global $smcFunc;

// Query: get all boards

$request = $smcFunc['db_query']('', '
    SELECT id_board, name
    FROM {db_prefix}boards
    ORDER BY id_board ASC'
);

$boards = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
    $boards[$row['id_board']] = $row['name'];
}
$smcFunc['db_free_result']($request);

// Loop through boards and list topics with titles
foreach ($boards as $id_board => $board_name) {

    echo "=== BOARD $id_board: $board_name ===\n";

    $request = $smcFunc['db_query']('', '
        SELECT t.id_topic, m.subject
        FROM {db_prefix}topics AS t
        JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
        WHERE t.id_board = {int:board}
        ORDER BY t.id_topic ASC',
        array(
            'board' => $id_board,
        )
    );

    while ($topic = $smcFunc['db_fetch_assoc']($request)) {
        echo "Topic ID: {$topic['id_topic']} | {$topic['subject']}\n";
    }

    $smcFunc['db_free_result']($request);

    echo "\n";
}

echo "Done.\n";
friendly
0
funny
0
informative
0
agree
0
disagree
0
like
0
dislike
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
Our Discord Server invitation link is https://discord.gg/jB2qmRrxyD

Tags:
 


dopetalk does not endorse any advertised product nor does it accept any liability for it's use or misuse





TERMS AND CONDITIONS

In no event will d&u or any person involved in creating, producing, or distributing site information be liable for any direct, indirect, incidental, punitive, special or consequential damages arising out of the use of or inability to use d&u. You agree to indemnify and hold harmless d&u, its domain founders, sponsors, maintainers, server administrators, volunteers and contributors from and against all liability, claims, damages, costs and expenses, including legal fees, that arise directly or indirectly from the use of any part of the d&u site.


TO USE THIS WEBSITE YOU MUST AGREE TO THE TERMS AND CONDITIONS ABOVE


Founded December 2014
SimplePortal 2.3.6 © 2008-2014, SimplePortal