Page 1 of 1

Odd request

Posted: Thu Nov 09, 2006 3:08 am
by alex.barylski
Edit: Actually just played with the forum listings...it's a decent example...I have never looked at the logic to render a collapsable forum list in phpBB - I have an idea of how it's done (easy enough) but I'd like to hear your perspective. Do they use a single recordset or are they two seperate datasets?

-------------------------------------------------------------EOE------------------------------------------------

But...

Does anyone have some fairly complicated list rendering code floatin' around?

Like a user list or something...but just the code and maybe at best a screenshot of the result...I'm looking to study how records are output...not that I don't already know how, not even because I want to see if your way is better...

But rather from a purely research perspective...I have a hypothesis about record data...but I need to look at some examples...

The forum listings is an example, but to trivial as it's easily solved...

Cheers :)

Posted: Thu Nov 09, 2006 6:14 am
by feyd
I have no idea what you're actually asking.

Posted: Thu Nov 09, 2006 6:16 am
by Chris Corbyn
feyd wrote:I have no idea what you're actually asking.
That's exactly what I thought :lol:

Posted: Thu Nov 09, 2006 7:25 am
by Maugrim_The_Reaper
Did you happen to study Obscurity in college? ;)

I think you need to provide a use case by way of explanation...

Posted: Thu Nov 09, 2006 10:29 am
by alex.barylski
Haha :P

Ok, I need either code and/or snapshot of a less than trivial rendering of records...

For example, given the dataset:

Code: Select all

$users = array(
  array('fname' => 'Joe', 'age' => 23, 'gender' => 'Male'),
  array('fname' => 'Moe', 'age' => 25, 'gender' => 'Male'),
  array('fname' => 'Foe', 'age' => 27, 'gender' => 'Male'),
  array('fname' => 'Boe', 'age' => 20, 'gender' => 'Male'),
  array('fname' => 'Toe', 'age' => 43, 'gender' => 'Male')
);
One might render like the following:

Code: Select all

for($i=0; $i<count($users); $i++){
  $color = $i & 1 ? 'Odd_Color' : 'Even_Color';
  echo '<div class="'.$color.'">'.$users[$i]['fname'].'</div>';  
}
But the above is really to trivial...I want to see a real world example that is more complicated...more states...

Like enabled, disabled, alternative colors, etc...

Cheers :)

Posted: Thu Nov 09, 2006 12:57 pm
by Chris Corbyn
8O :?:

What so you mean for example I wanted to highlight all people who are 20?

Code: Select all

for($i=0; $i < count($users); $i++)
{
    $color = $i % 2 ? 'Dark' : 'Light';
    if ($users['age'] == 20) $color = 'Highlighted';
    echo "<div class=\"".$color."\">".$users[$i]['fname']."</div>\n";
}
What's the purpose of this exercise again? I'm still not getting it.

Posted: Thu Nov 09, 2006 1:01 pm
by d3ad1ysp0rk
d11wtq wrote:What's the purpose of this exercise again? I'm still not getting it.
I think he wants to know if he's doing it in the best and most concise way.

Posted: Thu Nov 09, 2006 1:10 pm
by RobertGonzalez
I'd love to try to reply, but I still cannot wrap my mind around what is being asked. Is this a logic-inside-a-loop question?