Forum Moderators: coopster

Message Too Old, No Replies

Creating a Category Break/Divider

         

djburg42

3:25 pm on Jun 30, 2004 (gmt 0)

10+ Year Member



Hi again all...

I'm hoping some of the great folks here have experienced something along the lines of "breaks" while displaying query results before.

I'm pulling a series of fields from 2 tables based on a join. The fields are Name, AcctNum, Crate, Fees, Disc & Total. I then print them in a table but I want to create a divider when the AcctNum changes. I'm pulling it out of MySQL with an "Order By" option so that all entries with the same AcctNum are together but can't seem to get to causing a break/divider when that number/field changes.

Any advice?

Warboss Alex

3:30 pm on Jun 30, 2004 (gmt 0)

10+ Year Member



I did something like this once, can't remember how/why but I got it to work like so ..

$var = "";

while ($row = mysql_fetch_array()) {

if ($row['AcctNum']!== $var) do_something();

show_data();

$var = $row['AcctNum'];

}

$var is the value you want to check. Each time it takes a row from the database, it checks the value of $var against that row's 'AcctNum'. If it's different, output a divider or whatever you want (do_something()). It then shows the data and sets the value of $var to the current 'AcctNum'.

Hope it works for you,

Alex ...