Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-18-2008, 09:45 PM
marzar00 marzar00 is offline
Registered User
 
Join Date: Jun 2008
Posts: 22
SQL PHP and Sections!

G'day all,

I have been trying to modify Peter's code for displaying the sections when creating a new section. What I want is for the children of a section to be displayed below the parent with a hyphen in front of the child. Here is my code so far:

PHP Code:
<?php
// Generate a drop-down list of sections, only where section is not a child.
$result = $connector->query('select `sections`.`ID`, `sections`.`name` from sections where (`sections`.`parentid` =0) order by `sections`.`ID` asc');
// Save into array.
$topsect = $connector->fetchArray($result);
// For each, print them check for children.
foreach ($topsect as $top){
        echo
'<option value="'.$top['ID'].'">'.$top['name'].'</option>';
    
// Check if above section has children.
    
$result = $connector->query('select `sections`.`ID` , `sections`.`name` from sections where ( `sections` . `parentid` = '.$top['ID'].' ) order by `sections`.`name` asc');
    
// If has children print each with a '-' in front.
    
while($row = $connector->fetchArray($result)){
        echo
'<option value="'.$row['ID'].'">-'.$row['name'].'</option>';
    }
}
?>
At the moment all I get is three lines:
None
1
U

Any ideas?

Thanks in advance,
Marzar

Last edited by marzar00; 11-18-2008 at 09:49 PM. Reason: changed the parent from $row to $top
Reply With Quote
  #2 (permalink)  
Old 04-06-2009, 05:05 AM
dp2 dp2 is offline
Registered User
 
Join Date: Apr 2009
Posts: 4
You may not be aware that OtterCMS uses TAGS to pull data from the database into the template.

Try the content option button in the WYSIWYG editor. To display content of a section folder. The content would be the child.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 05:44 PM.





Acceptable Use Policy

WebMediaBrands

internet.comMediabistrojusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Shopping | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0