[PHP] Setting up a 2 Column Display for SQL Recordset

2010-08-13 Thread DealTek
newbie question:

Hi Folks,

I have a php / sql data recordset that has 200 names that I want to display in 
a 2 column display ( down on left then down on right side - not left right - 
left right).

So I can create a 2 column table. Then I need to split the data result in 2 
parts - so part 1 (1-100 records) is on the left column and part 2 (101 - 200 
records) is on the right column.

Q: I'm not quite sure how to split / display the records ... Is there some kind 
of internal sql rec number that I can monitor? What is the best way to set this 
up?



--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-10]




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



Re: [PHP] Setting up a 2 Column Display for SQL Recordset

2010-08-13 Thread chris h
Dave I would look into something like the array_slice function.

http://us3.php.net/manual/en/function.array-slice.php

With this function you could create two arrays - one for the left column,
and one for the right column - and iterate through them simultaneously.

i.e. untested: given $allNames is an array with all 200 names
--
$firstNameSet = array_slice($allNames, 0, 100);
$secondNameSet = array_slice($allNames, 100);

foreach ($firstNameSet as $key = $nameA) {
 $nameB = $secondNameSet[$key];
 ...
 ...
}
-

Alternatively you can use a nested query to pull the results in two sets
directly from the sql db.


Hope that helps
Chris.


On Fri, Aug 13, 2010 at 12:51 PM, DealTek deal...@gmail.com wrote:

 newbie question:

 Hi Folks,

 I have a php / sql data recordset that has 200 names that I want to display
 in a 2 column display ( down on left then down on right side - not left
 right - left right).

 So I can create a 2 column table. Then I need to split the data result in 2
 parts - so part 1 (1-100 records) is on the left column and part 2 (101 -
 200 records) is on the right column.

 Q: I'm not quite sure how to split / display the records ... Is there some
 kind of internal sql rec number that I can monitor? What is the best way to
 set this up?



 --
 Thanks,
 Dave - DealTek
 deal...@gmail.com
 [db-10]




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