vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How to list forum categories on a non-vb page (https://vborg.vbsupport.ru/showthread.php?t=13695)

Raptor 04-11-2001 04:20 AM

I saw this on another post (made for v1.1.5)

<?php
require("forum/admin/config.php3");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM CATEGORY ORDER BY title ASC";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"1\" FACE=\"Verdana\"> °
<A HREF=\"http://digital-forums.com/forum/index.php3?categoryid=$latest_array[categoryid]\">$latest_array[title]</A></FONT><BR>";
}

?>

But I just get this error msg:
Warning: Supplied argument is not a valid MySQL result resource in /home/dforums/public_html/list_categories.php3 on line 7

I'm using v2 beta 5 - can someone please get this working for me

thanks in advance !

Wayne Luke 04-11-2001 04:30 AM

Here this shows the first two levels of forums...

Code:

<?php
require("global.php");
//Forum info
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
while ($forum=$DB_site->fetch_array($forums)) {
  if ($forum[parentid] == -1) {
    echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><b><a href=\"http://sitepointforums.com/forumdisplay.php?forumid=".$forum[forumid]."\">".$forum[title]."</a></b></font><br>");
    if ($forum[allowposting] == 0) {
      $parent=$forum[forumid];
      $subforums=$DB_site->query("SELECT * FROM forum WHERE displayorder<>0 AND active=1 AND parentid=".$parent." ORDER BY displayorder");
      while ($subforum=$DB_site->fetch_array($subforums)) {
        echo ("&nbsp;&nbsp;<font face=\"Arial, Helvetica, sans-serif\" size=\"-3\"><a href=\"http://sitepointforums.com/forumdisplay.php?forumid=".$subforum[forumid]."\">".$subforum[title]."</a></font><br>");
      }
    }
  }
}
$DB_site->free_result($forums);
unset($forum);

?>


Raptor 04-11-2001 05:11 PM

this is great thanks

couple of things:

Only works when calling the script when its in the /forum dir. But gives Fatal error: Failed opening required './admin/config.php3' (include_path='.:/usr/local/lib/php') in /home/dforums/public_html/forum/global.php3 on line 49 when outside the forum dir - is this something to do with the chdir command ?

And how to display topics without the sub topics ?

Many thanks

Raptor 04-11-2001 05:17 PM

ok fixed the first part :)

chdir("/home/dforums/public_html/forum");
require("global.php3");

now how to list just the topics and not the sub topics - i'll have a go at doing it myself while awaiting help from you guys :)

Raptor 04-11-2001 05:20 PM

ok i did it - is the code correct or is there anything in there that doesn't need to be there ?

<?php
chdir("/home/dforums/public_html/forum");
require("global.php3");
//Forum info
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
while ($forum=$DB_site->fetch_array($forums)) {
if ($forum[parentid] == -1) {
echo ("<font face=\"Verdana\" size=\"2\"><b><a href=\"http://digital-forums.com/forum/forumdisplay.php3?forumid=".$forum[forumid]."\">".$forum[title]."</a></b></font><br>");
if ($forum[allowposting] == 0) {
$parent=$forum[forumid];

}
}
}
$DB_site->free_result($forums);
unset($forum);

?>

trilizio 04-11-2001 05:26 PM

WITH SUB CATEGORIES
PHP Code:

<?
require("/home/dforums/public_html/forum/global.php");
//Forum info
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
while ($forum=$DB_site->fetch_array($forums)) {
  if ($forum[parentid] == -1) {
    echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><b><a href=\"http://www.yourdomain.com/forum/forumdisplay.php?forumid=".$forum[forumid]."\">".$forum[title]."</a></b></font><br>");
    if ($forum[allowposting] == 0) {
      $parent=$forum[forumid];
      $subforums=$DB_site->query("SELECT * FROM forum WHERE displayorder<>0 AND active=1 AND parentid=".$parent." ORDER BY displayorder");
      while ($subforum=$DB_site->fetch_array($subforums)) {
        echo ("  <font face=\"Arial, Helvetica, sans-serif\" size=\"-3\"><a href=\"http://www.yourdomain.com/forum/forumdisplay.php?forumid=".$subforum[forumid]."\">".$subforum[title]."</a></font><br>");
      }
    }
  }
}
$DB_site->free_result($forums);
unset($forum);

?>

WITHOUT SUB CATEGORIES
PHP Code:

<?
require("/home/dforums/public_html/forum/global.php");
//Forum info
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
while ($forum=$DB_site->fetch_array($forums)) {
  if ($forum[parentid] == -1) {
    echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><b><a href=\"http://www.yourdomain.com/forum/forumdisplay.php?forumid=".$forum[forumid]."\">".$forum[title]."</a></b></font><br>");
}
}
$DB_site->free_result($forums);
unset($forum);

?>


trilizio 04-11-2001 05:27 PM

Thats should work. If it doesn't then I dunno ;)

the_sisko 04-11-2001 07:46 PM

Great
..but it shows my private forums and categories to normal users!!!

Wayne Luke 04-11-2001 09:46 PM

You will have to add a WHERE clause in there to exclude private categories and forums by checking the forums private status.

I have a simple toggle switch in my database called "showactive" if it is true then we show it, if not we don't. The reason for this is we don't want some forums showing up in external scripts even if they are public like General Chit Chat forums and Member only forums.

Raptor 04-11-2001 10:07 PM

could you list the code please ?


All times are GMT. The time now is 08:12 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01112 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete