RE: [PHP-DB] displaying result across 3 cells - where did I go wrong?

2003-08-14 Thread Aaron Wolski
Hey John,

Thanks for spotting that.

So.. do I need to use 2 different incrementors? $z and say $x for each
part?

I basically pieced this code together from several examples I found so
forgive forgive the fact I don't know a whole lot about the code even
though I've tried to understand it as much as possible *shrugs*

Aaron

-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: August 5, 2003 9:08 AM
To: Aaron Wolski; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] displaying result across 3 cells - where did I go
wrong?

From: "Aaron Wolski" <[EMAIL PROTECTED]>
>
> while($z++ %3 !==0)
[snip]
> echo (++$z %3 == 0) ? '' : '';

The first time through your code, $z is zero. Since the "thread titles"
don't match, your going to get to your while loop above. $z is zero, so
your
while loop isn't executed, but $z is incremented to one. Then, later in
your
code you increment $z to two and check for the modulus 3. So basically,
every time you switch "thread titles", $z is incremented one more than
it
should be and you miss out on one cell in the following row.

---John Holmes...


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




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



Re: [PHP-DB] displaying result across 3 cells - where did I go wrong?

2003-08-05 Thread CPT John W. Holmes
From: "Aaron Wolski" <[EMAIL PROTECTED]>
>
> while($z++ %3 !==0)
[snip]
> echo (++$z %3 == 0) ? '' : '';

The first time through your code, $z is zero. Since the "thread titles"
don't match, your going to get to your while loop above. $z is zero, so your
while loop isn't executed, but $z is incremented to one. Then, later in your
code you increment $z to two and check for the modulus 3. So basically,
every time you switch "thread titles", $z is incremented one more than it
should be and you miss out on one cell in the following row.

---John Holmes...


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



Re: [PHP-DB] displaying result across 3 cells - where did I go wrong?

2003-08-05 Thread CPT John W. Holmes
From: "Aaron Wolski" <[EMAIL PROTECTED]>
> So.. do I need to use 2 different incrementors? $z and say $x for each
> part?
>
> I basically pieced this code together from several examples I found so
> forgive forgive the fact I don't know a whole lot about the code even
> though I've tried to understand it as much as possible *shrugs*

You could try something like this:

while($z % 3 !== 0)
{
  $z++;
  ...
}

That way $z is only incremented when there are left over cells to be filled.
You may have to play around with it for a bit.

---John Holmes...


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



[PHP-DB] displaying result across 3 cells - where did I go wrong?

2003-08-05 Thread Aaron Wolski
Hi All,
 
I'm trying to display results across 3 cells - for example:
 
#5 Perle Cotton
 
223 | 225 | 301
304 | 326 | 333
 
#12 Perle Cotton
 
211 | 223 | 224
225 | 356 | 
 
#4 Braid 
 
95   | 100HL | 102
 
Right NOW it is displaying like:
 
#5 Perle Cotton  
 
223 | 225  
301 | 304| 326
 
#12 Perle Cotton
  
211 | 223  
224 | 225| 356  
 
#4 Braid 
 
95 | 100HL  
102
 
This is the code I am working with:
 
$z =0;
while ($thread = db_fetch($tresult)) 
{ 
 
// if z is divisible by 3 
echo ($z %3 == 0) ? '' : '';  
 
if ($thread_type != $thread['type']) 
{
 
echo "{$thread[type]}\n";
 

 
while($z++ %3 !==0) 
{
 
// if
not enough tds - add empty tds until end of tr 
echo
' '; 
} 
 
 // everytime we get here - we have just
filled a tr with tds, 
 // so start new tr and output type,
then start another new tr 
echo ' type
'; 
$thread_type = $thread[type]; 
}
 
echo ' '.$thread[colourID].' '; 
// end the tr on every third cycle 
echo (++$z %3 == 0) ? '' : '';
}
 
 
The HTML looks like:
 


 

 #5 Perle Cotton 

 

 223 
 225 


  301 
 304 
 326 


 333 
 
 


 #12 Perle Cotton 


 211 
 223 


 224 
 225 
 356 




 #4 Braid 


 95 
 100HL 


 102 
 
 
 
can ANYONE see where I have gone wrong?
Any guidance is appreciated.
 
Thanks!
 
Aaron