Jump to content


Photo

change column data displayed


  • Please log in to reply
2 replies to this topic

#1 1042

1042
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 25 October 2006 - 10:54 AM

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

id1|id2
id3|id4
id5|id6

 $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>";

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

id1|id4
id2|id5
id3|id6

thanks to all in advance.

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 25 October 2006 - 11:22 AM

OK, you need to use MySQL result...  I'm just looking up some code I have that will do the job.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 1042

1042
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 26 October 2006 - 07:29 AM

thanks, i would really appreciate your help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users