Jump to content
xisto Community
biggiebi

Confusing! Help

Recommended Posts

I suck at explaining.

So here I can get data from the MySQL database and I can print the info.

But like how do I make it so it show a new

<tr>									 <td class="topic"><?php echo $title ?></td>								 </tr>								 <tr>									 <td class="contenttext">										 <?php while ( $data = mysql_fetch_array($result) ) {	echo bb2html($data['message']) . '<br />';} ?>									   </td>								   </tr>
everytime there's a new content?

cause when i
echo bb2html($data['message'])
it shows all of flexbb_threads in 1
<tr><td></td></tr>

So like when i do
echo bb2html($data['message'])
I want it show
<tr><td>Title1</td><td>Content1</td></tr><tr><td>Title2</td><td>Content2</td></tr>

Edited by biggiebi (see edit history)

Share this post


Link to post
Share on other sites

You have to place the <td> and all the other tags inside the loop.
Like:

<tr>   <td class="topic"><?php echo $title ?></td></tr><tr><?php while ( $data = mysql_fetch_array($result) ) {?>   <td class="contenttext"><?php	echo bb2html($data['message']) . '<br />';?></td>} ?></tr>

But this way, you'll only have one title (and I suppose you want a title per 'message', not ? ). Best way it to do a sqlquery where you select title and message and store it in a variable. This way, you could make something like this (supposing you store the data from the query in $sql).
<?phpwhile ($tmp = mysql_fetch_object($sql) {?><tr><td><?php echo $tmp->title; ?></td></tr><tr><td><?php echo $tmp->message; ?></td></tr>}?>

Share this post


Link to post
Share on other sites

nvm i got it to work...
now do i make it so like every 5 news there's a new page
and it shows the next 5 news.

You need to modify your sql query to get 5 records at a time, like this:
<?php$limit=5;$start=0;$sql = "SELECT col1, col2 FROM table LIMIT " . $start . ", " . $limit;$rs = mysql_query($sql) or die(mysql_error());
After that loop your records as usual, and then remember to increase the $start variable by adding the value of the $limit variable.

Best regards,

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

×
×
  • 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.