Jump to content

change column data displayed


1042

Recommended Posts

Hi all, i have the following code that displays data in a double column in the format

id1|id2
id3|id4
id5|id6

[code]
$getpress = mysql_query("SELECT * FROM events ORDER BY eventid ASC");//query the database for all of the news
$i = 1; // counter var
$cols = 2; // or however many columns you want
echo "<table>";
while($r=mysql_fetch_array($getpress)){//while there are rows in the table
extract($r);//remove the $r so its just $variable


if ($i == 1) echo "<tr>"; // start new row
    echo "<td td width=\"50%\"><font color=#000000><strong>$eventtitle</strong></font><br>
<font color=black>$eventinfo </font><br>
<font color=blue>$eventlink  </font><br></td>";
    if ($i == $cols) { // we've reached the end of our number of cols so end the row and reset the counter
        $i = 0;
        echo "</tr>";
    }
    $i++; // increment our counter
}
if ($i != $cols) echo "</tr>"; // if we haven't finished off the row end it now
echo "</table>"; [/code]

what would i need to change to display the data in the format

id1|id4
id2|id5
id3|id6

thanks to all in advance.
Link to comment
https://forums.phpfreaks.com/topic/25040-change-column-data-displayed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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