|
|
|
|
![]() ![]() |
Oct 21 2007, 07:56 PM
Post
#1
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 20 Joined: 26-August 06 Member No.: 15,544 |
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 CODE <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 CODE echo bb2html($data['message']) it shows all of flexbb_threads in 1 CODE <tr><td></td></tr> So like when i do CODE echo bb2html($data['message']) I want it show CODE <tr><td>Title1</td><td>Content1</td></tr><tr><td>Title2</td><td>Content2</td></tr>
This post has been edited by biggiebi: Oct 21 2007, 07:59 PM |
|
|
|
Oct 21 2007, 08:39 PM
Post
#2
|
|
|
Way Out Of Control - You need a life :) Group: [HOSTED] Posts: 1,025 Joined: 2-August 05 From: Kapellen (Antwerp, Belgium) Member No.: 7,585 |
You have to place the <td> and all the other tags inside the loop.
Like: CODE <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). CODE <?php
while ($tmp = mysql_fetch_object($sql) { ?> <tr> <td> <?php echo $tmp->title; ?> </td> </tr> <tr> <td> <?php echo $tmp->message; ?> </td> </tr> } ?> |
|
|
|
Oct 21 2007, 08:56 PM
Post
#3
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 20 Joined: 26-August 06 Member No.: 15,544 |
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. |
|
|
|
Oct 22 2007, 12:47 AM
Post
#4
|
|
|
Super Member Group: [HOSTED] Posts: 750 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
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: CODE <?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, |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 7th September 2008 - 10:08 PM |