Help! Confused...

14 posts by 2 authors in: Forums > CMS Builder
Last Post: May 26, 2013   (RSS)

Clients are sometimes a pain, but where we would we be without them!

I have a request from my client to make a change to the dropdown menu.  What he wants to see on the menu are the following:

squadron (currently there)

number of articles under 3 days old for the squadron

total number of articles for the squadron

in this format [ie.  537 Gander (3/7)  ]

Here is the code I am using:

  // load list records from 'squadron_news'
  list($squadron_newsRecords, $squadron_newsMetaData) = getRecords(array(
    'tableName'   => 'squadron_news',
    'loadUploads' => true,
    'allowSearch' => true,
    'orderBy'  => 'publishDate DESC',
 
  ));

and

<div id="contentContainer"><!-- Start main content wrapper -->
                <div id="content"><!-- Start content -->
                
                <h2>Squadron News</h2>
                    
                <?php if (@$_REQUEST['squadron']): ?>
                        <br/>
                
                      <?php foreach ($squadron_newsRecords as $record): ?>
                              
                     
                     <br />
                      <h2><?php echo htmlencode($record['title']) ?></h2>
                      <b>Squadron</b>: <?php echo $record['squadron:label'] ?><br/>
                      <?php echo $record['content']; ?>
                      <ul>
                      <?php foreach ($record['documents'] as $index => $upload): ?>
                      <li><a href="<?php echo $upload['urlPath'] ?>"><?php echo $upload['info1'] ?></a></li>
                          <?php endforeach ?>
                      </ul>
                      
                      <hr/>
                    <?php endforeach ?>
                
                    <?php if (!$squadron_newsRecords): ?>
                      No records were found!<br/><br/>
                    <?php endif ?>
              
            <?php endif ?>
                   
                                            
                </div><!-- End content -->
                <div class="clearer"></div>
            </div><!-- End main content wrapper -->
            <div id="sidebarContainer">
                <div id="subMenu"></div>
                <div class="clearer"></div>
                <div id="sidebarHeader"></div>
                <div id="sidebar">
                <br />
                <form name="choose" action="" method="get">
                Choose a squadron:
                <select name="squadron" size="25" style="width: 220px;">
                
                  <?php foreach (getListOptions("squadron_news", "squadron") as $value => $label): ?>
                    <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['squadron']);?>><?php echo htmlspecialchars($label);?></option>
                <?php endforeach; ?>
                </select>
                <input type="submit" value="Submit">
                </form>

        </div>
        </div>

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By Jason - May 26, 2013

Hi,

You can use mysql_count() to total us records.

For example:

Choose a squadron:
                <select name="squadron" size="25" style="width: 220px;">
                
                  <?php foreach (getListOptions("squadron_news", "squadron") as $value => $label): ?>
                    <?php
                      $threeDaysAgo  = date("Y-m-d", strtotime("-3 days"));
                      $totalArticles = mysql_count("squandron_news", "squadron = '".mysql_escape($value)."'");
                      $newArticles   = mysql_count("squandron_news", "squadron = '".mysql_escape($value)."' AND createdDate > '".mysql_escape($threeDaysAgo)."'");
                    ?>
                  
                    <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['squadron']);?>><?php echo htmlspecialchars($label);?>(<?php echo $newArticles;?>/<?php echo $totalArticles;?>)</option>
                <?php endforeach; ?>
                </select>

Please note that this code hasn't been tested.

Hope this helps get you started.

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Thanks Jason!

i will try it tonight.

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By northernpenguin - May 26, 2013 - edited: May 26, 2013

Jason:  worked great except that you spelled "squadron" incorrectly in "squadron_news"!  Had me stumped for a bit until I noticed the spelling mistake.

Thank you very much, this is working exactly as advertised!

Ragi

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke