Jump to content
xisto Community
Sign in to follow this  
biggiebi

Bbc?

Recommended Posts

Well I'm trying to get data from my MySQL database and post it on my frontpage.

This is the query

SELECT name, message, poster FROM flexbb_threads WHERE id = 1
and the message is in BBC. so yeah...

Share this post


Link to post
Share on other sites
$result = mysql_query("SELECT `name`, `message`, `poster`, FROM `flexbb_threads` WHERE `id` = 1");$data = mysql_fetch_array($result);$data['message'] = parse_bbcode($data['message']);echo $data['name'] . '<br />';echo $data['message'];

First, you retrieve the message from the database and insert one message data into an array (you would call mysql_fetch_array() again for the next row in the result set). After that, you call the function that will replace the BBCode with HTML code; of course, you need to write this yourself (or download appropriate PHP code from a scripting web site), as it is not a part of PHP (I recommend doing so with regular expressions). Finally, you are ready to output data.

Share this post


Link to post
Share on other sites

For that, you will need to learn MySQL. As I don't know the structure of flexbb_thread, nor exactly what you want to do, I can't help you.

Share this post


Link to post
Share on other sites

I've tried this to show all the content of the announcements forum.

$result = mysql_query("SELECT name, message, poster FROM flexbb_threads WHERE forumid = 1");$data = mysql_fetch_array($result);echo $data['message'];
name is the Title of the thread, message is the content, poster is the poster. forumid is the forum. forumid = 1 is the announcements. so yeah

http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

When you use SELECT in MySQL, you are given a results table if there are multiple rows. mysql_fetch_array returns only one row, so you would have to use a loop in order to display all the announcements..

 

$result = mysql_query("SELECT `name`, `message`, `poster`, FROM `flexbb_threads` WHERE `forumid` = 1");while ( $data = mysql_fetch_array($result) ) {	echo $data['message'] . '<br />';}

Share this post


Link to post
Share on other sites

well could you help me with this?

<?php$dbhost = 'host';$dbuser = 'username';$dbpass = 'password';$dbname = 'database';$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');mysql_select_db($dbname);$result = mysql_query("SELECT name, message, poster FROM flexbb_threads WHERE id = 1");$data = mysql_fetch_array($result);$data['message'] = bb2html($data['message']);?> <div align="center">							 <table border="0" width="85%" class="contentbox">								 <tr>									 <td class="topic"><?php echo $data['name']; ?></td>								 </tr>								 <tr>									 <td class="contenttext">										 <?php echo $data['message']; ?>									   </td>								   </tr>								   <tr>									   <td class="by">										   Written by <?php echo $data['poster']; ?></a>									   </td>								   </tr>							</table>						</div><br><br><?php mysql_close($conn); ?>

Edited by biggiebi (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.