Odd request

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Odd request

Post 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 :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I have no idea what you're actually asking.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

feyd wrote:I have no idea what you're actually asking.
That's exactly what I thought :lol:
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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...
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post 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 :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
Post Reply