RE: Walking through a bunch of MySQL Records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yeah Jim - that's better than mine.
Miles
At 03:28 PM 11/14/2005, Jim Moseby wrote:
>
> I have a question.
> I want to display a group of records pulled form a MySQL db
> in the following
> fashion.
>
> 1        6
> 2        7
> 3        8
> 4        9
> 5        10
>
> Now I can easily figure out how to display the records as
>
> 1        2
> 3        4
> 5        6
> 7        8
> 9        10
>
> But since I am in an HTML table and the need to display the
> <TR> and </TR> I
> am not sure how to make th logic so that I can get the first
> listing. Can
> anyone help me out?? Need more information??


You could load up an array with your result set:

$records=array();
$rownum=0;
while ($row=mysql_fetch_array($result)){
  $rownum++;
  records[$rownum]=$row['data'];
}

...then use $rownum/2 to determine the second column:

for ($i==1;$i<=$rownum/2;$i++){
  $col1=$i;
  $col2=$i+($rownum/2);
  echo "<tr>$record[$col1]</tr>";
  echo "<tr>$record[$col2]</tr>";
}

There are probably much better ways to do this, but this is a start.

JM

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux