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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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