Re: [sqlite] Alternating Output

2004-07-24 Thread Randall Fox
On Sat, 24 Jul 2004 09:22:06 +0100, you wrote: >When I've done this in the past I've always handled alternating colours >in the web scripting side. You have to loop through all the records to >display them from the query, so I maintain a 'current record count'. If >it's odd, format the row whit

Re: [sqlite] Alternating Output

2004-07-24 Thread Gary Lawton
When I've done this in the past I've always handled alternating colours in the web scripting side. You have to loop through all the records to display them from the query, so I maintain a 'current record count'. If it's odd, format the row white, if it's even format the row grey. For example in

Re: [sqlite] Alternating Output

2004-07-23 Thread Randall Fox
On Fri, 23 Jul 2004 18:50:49 +0200, you wrote: > >> How do you renumber an index anyway? > >Hmm ... given the tables > work (idx, sortcrit) > storeroom(rowcount integer) > >where 'idx' may be the index to renumber and 'sortcrit' a sorting criteria. > >I would try to do something like

Re: [sqlite] Alternating Output

2004-07-23 Thread Daniel Franke
> How do you renumber an index anyway? Hmm ... given the tables work (idx, sortcrit) storeroom(rowcount integer) where 'idx' may be the index to renumber and 'sortcrit' a sorting criteria. I would try to do something like the code below, but I just remembered that sqlite does

Re: [sqlite] Alternating Output

2004-07-22 Thread Randall Fox
The trigger is a nice idea, but renumbering the index won't work, since the index might be used as a key to link the record to another table.. I guess I could use a new index, just for this purpose but that seems to be a waste of resources.. How do you renumber an index anyway? Randall Fox On

Re: [sqlite] Alternating Output

2004-07-22 Thread Daniel Franke
> I am just wondering if it was done or there is an easy way.. As suggested by Kurt, given a subsequent index from idx = 1 ... N, you may use color = idx%2 to compute your color. To work around the problem of insert/delete, I'd try to employ a trigger on these events to renumber the index (idx)

Re: [sqlite] Alternating Output

2004-07-21 Thread Randall Fox
Ya.. I thought about all that, but the web pages will be built based on queries, so the support needs to come from the SQL statement. Using the key value is just not practical. What I am thinking about is adding a custom function (I think sqlite supports that) and just using a boolean static vari

Re: [sqlite] Alternating Output

2004-07-21 Thread Kurt Welgehausen
> Is there an easy way to have an "alternating" column value ...? No easy or reliable way that I can see. Given a table with an integer primary key (ipk), you could let (ipk % 2 == 0) => white and (ipk % 2 != 0) => gray, but that would work only if (1) you never delete a row or (2) you delete onl

[sqlite] Alternating Output

2004-07-20 Thread Randall Fox
Is there an easy way to have an "alternating" column value in a query, using sqlite ? I want to have a column that alternates its value on every row. The application is web based. I want to alternate colors for each row in a table.. Something row1 = gray background, row2 = white, row3=grey, ro