CptMcGillicudy Posted February 26, 2009 Share Posted February 26, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/ Share on other sites More sharing options...
MadTechie Posted February 26, 2009 Share Posted February 26, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/#findComment-771925 Share on other sites More sharing options...
CptMcGillicudy Posted February 26, 2009 Author Share Posted February 26, 2009 Thank you MadTechie 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) Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/#findComment-771951 Share on other sites More sharing options...
MadTechie Posted February 26, 2009 Share Posted February 26, 2009 Oh.. my... try this echo $thread['title']." - By ".$thread['postusername']."<br>"; I forgot the $.. (shakes head in shame) Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/#findComment-771954 Share on other sites More sharing options...
CptMcGillicudy Posted February 26, 2009 Author Share Posted February 26, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/#findComment-771995 Share on other sites More sharing options...
MadTechie Posted February 26, 2009 Share Posted February 26, 2009 try this echo "<a href=\"http://www.ydnfutc.com/Forum/showthread.php?t=".$thread['threadid']."\">".$thread['title']."</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/#findComment-772002 Share on other sites More sharing options...
CptMcGillicudy Posted February 26, 2009 Author Share Posted February 26, 2009 Thank you so much MadTechie! That works like a charm. You have been friendly and a lot of help. Hopefully I'll be able to teach myself the rest This has been solved Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/#findComment-772041 Share on other sites More sharing options...
MadTechie Posted February 26, 2009 Share Posted February 26, 2009 Well i do try Can you click the topic solved button please Quote Link to comment https://forums.phpfreaks.com/topic/147028-solved-processing-data-array/#findComment-772045 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.