On Thu, Apr 23, 2015 at 8:00 AM, dealTek <dealtek@xxxxxxxxx> wrote: > Hi all, > > NEWBIE: Here's the issue - I am trying to split and find query on a page > into 2 columns using = array_slice()....... > > If the get found set count is an EVEN amount - then all is ok - but if not > then I get an error and the last record on the bottom right like..... > > Fatal error: Call to a member function getField() on a non-object in > /home/test.php on line xxx > > I think it has to do with LENGTH param... > > - if I make length be $part1 -0 then I get error on bottom right if NOT > even total > - if I make length be $part1 -1 then I get NO error on bottom right if NOT > even total - BUT I DO NOT GET FULL RESULT (MISSING A RECORD)... > > > Q: HOW CAN I SET THIS UP SO NO ERRORS WHEN RESULT OF found set count is > *NOT* an EVEN amount ? > > > > > > <?php > $allrows = $mytest_result->getFoundSetCount(); > $part1 = round($mytest_result->getFoundSetCount() / 2); > ?> > > > > > <br /> > all <?php > echo $allrows; ?><br /> > part1 <?php > echo $part1; ?><br /> > <br /> > > > > > <?php > > > // ERROR unless use -1 - check if correct ??? now ok i guess > > $firstNameSet = array_slice($mytest_result->getRecords(), 0, $part1 -0 ); > // ERROR unless use -1 - check if correct ??? now ok i guess > > $secondNameSet = array_slice($mytest_result->getRecords(), $part1 -0 ); // > ERROR unless use -1 - check if correct ??? now ok i guess > > ?> > > > > <?php > > foreach ($firstNameSet as $key => $nameA) { > $nameB = $secondNameSet[$key]; > ?> > > > <?php echo $nameA->getField('myfield'); ?> > > <?php > } ?> > > > > > > <?php > > foreach ($firstNameSet as $key => $nameA) { > $nameB = $secondNameSet[$key]; > ?> > > > <?php echo $nameA->getField('myfield'); ?> > > divs here etc...... > > <?php echo $nameB->getField('myfield'); ?> > > > > <?php > } ?> > > Do you have pseudo code on what you want to achieve? > -- > Thanks, > Dave - DealTek > dealtek@xxxxxxxxx > [db-15] > > -- Marcos | I love PHP, Linux, and Java <http://javadevnotes.com/java-string-split-pipe-examples>