Jump to content

Recommended Posts

Hi,

 

I'm hoping someone can help me out with this problem. I just recently purchased a vBulletin board for my website, and am trying to integrate forum threads into my main website index. I've already received some help from vBulletin.org, but they won't help me beyond this point. The person who helped me made me use this code:

 

<?php 

$curdir = getcwd();
chdir('./Forum');
require_once('global.php');
chdir($curdir);
$threads = $vbulletin->db->query_read("
    SELECT *
    FROM " .TABLE_PREFIX. "thread
    WHERE forumid = 2
    ORDER BY dateline DESC
    LIMIT 5
 ");

while ($thread = $vbulletin->db->fetch_array($threads))
{
    	// thread data is in $thread
}  ?>

 

That code works because it doesn't stretch the tables on my website anymore, but it doesn't display anything. This is the result of using that: http://www.ydnfutc.com/layoutsliced.php (The big white content box on the right is supposed to house the data). I asked the guy how to display the data and he said

As mentioned, all the thread's data is in an array in $thread. You need to process this data to whatever way you want.

 

I used to use a phpBB board, and this was the code I used on a previous website: http://deceptive-logic.com/tutorial/php/topic

 

I am only a novice coder, so your help and patience is greatly appreciated. My end result is to basically have my forum administrators post news, and that news be displayed on the main page.

 

Thank you in advanced! If you have any questions just PM me or ask them here.

-Walter

 

 

Link to comment
https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/
Share on other sites

Okay i havn't code with vB  but that code seams to be done..

 

So to continue i'll get to get some  extra info..

 

1. what you have in the array

2. what do you want to display ?

 

to get the array details

try this and post the results back

 

while ($thread = $vbulletin->db->fetch_array($threads))
{
       // thread data is in $thread
} 

 

to

while ($thread = $vbulletin->db->fetch_array($threads))
{
       echo "<pre>";var_dump($thread);die;
} 

 

This is just for getting the array info to post back here

ie

[name] = (string)"MadTechie",
[userid] = (int)12
etc

 

once you have that

you can update code above to

while ($thread = $vbulletin->db->fetch_array($threads))
{
       echo thread['name']." - ".thread['userid']."<br>";
} 

 

Hope that helps

Thank you MadTechie  ;D

 

Here is the array dump:

 

array(27) {
  ["threadid"]=>
  string(2) "49"
  ["title"]=>
  string(39) "Ydnfutc survey pt.1&2! Please read!"
  ["prefixid"]=>
  string(0) ""
  ["firstpostid"]=>
  string(3) "220"
  ["lastpostid"]=>
  string(3) "380"
  ["lastpost"]=>
  string(10) "1235603496"
  ["forumid"]=>
  string(1) "2"
  ["pollid"]=>
  string(1) "0"
  ["open"]=>
  string(1) "1"
  ["replycount"]=>
  string(2) "12"
  ["hiddencount"]=>
  string(1) "0"
  ["deletedcount"]=>
  string(1) "0"
  ["postusername"]=>
  string( "Zero[03]"
  ["postuserid"]=>
  string(1) "2"
  ["lastposter"]=>
  string(9) "Positive-"
  ["dateline"]=>
  string(10) "1235421718"
  ["views"]=>
  string(3) "103"
  ["iconid"]=>
  string(1) "4"
  ["notes"]=>
  string(0) ""
  ["visible"]=>
  string(1) "1"
  ["sticky"]=>
  string(1) "0"
  ["votenum"]=>
  string(1) "0"
  ["votetotal"]=>
  string(1) "0"
  ["attach"]=>
  string(1) "0"
  ["similar"]=>
  string(0) ""
  ["taglist"]=>
  NULL
  ["wrdate"]=>
  string(0) ""
}

 

I updated the code you gave me to this:

 

while ($thread = $vbulletin->db->fetch_array($threads))
{
       echo thread['title']." - By ".thread['postusername']."<br>";
} 

 

When I updated the code on the website, I get this error:

 

Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/blakecul/public_html/indextest.php on line 67

 

(Line 67 is the line with echo in it)

 

Thank you! That seems to do the trick.

 

One last question, I want to link the title of the thread to the thread itself, so basically I want to do something like this

 

<a href="http://www.ydnfutc.com/Forum/showthread.php?t=$thread['threadid']">$thread['title']</a>

 

Where the xx is ['threadid']. So basically, I need to link $.thread['title']. However I can't get it to work. Is there a proper way to go about doing that?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.