You are here: Re: PHP / Mysql - Retreive "Next" Row data in "this" row « PHP Programming Language « IT news, forums, messages
Re: PHP / Mysql - Retreive "Next" Row data in "this" row

Posted by Toby Inkster on 01/03/07 17:53

craig.keightley wrote:

> value 1
> value 1
> value 1
> SHOW ROW
> value 2
> value 2
> SHOW ROW
> value 3
> value 3
> SHOW ROW
> value 4
> value 4
> SHOW ROW

Thinking laterally, is "SELECT DISTINCT" an option?

If not, the basic technique is this:

<?php
$oldvals = array();

while ($newvals = fetch_row_from_db())
{
if ($newvals is different from $oldvals)
{
print $oldvals;
}
$oldvals = $newvals;
}

print $oldvals;
?>

You will need to adapt that to your situation.

This way, rather than trying to "look ahead" to the next row in the data
set, you're actually "printing behind" the previous row. Same effect, but
much easier to implement, because the next row is always a mystery,
whereas the previous row is already known.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация