Is it possible to create 2 columns filed?

11 posts by 2 authors in: Forums > CMS Builder
Last Post: January 23, 2013   (RSS)

Hi guys,

There are years and monthly fields on the section.

Each month have 2 fields information.

1) Is it possible to build a section like this? (please see the attachment image)

2) In my front page. How can I display the full month information when choose a year?

It look like

When I choose year.

The page will display all 12 monthes information.
Each month have 2 field information.

I use mutli-section to biuld the pages. It seems not fit the need.

Jac

-Jax H.
Attachments:

2-columns.jpg 99K

Hi Jac,

I just to confirm what you're after; so each record can have multiple years of data. For example, one record might have data for 2012, 2011, 2010, etc, and not just for one year? 

Currently CMS Builder doesn't support having two fields side by side. You would have to have to a have them in a row. I've attached a screenshot of a layout you could try. 

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hi Gerg

It nice to hear from you.

Do you have 2) solution?

I would like to display the full 12 month information when choose a year.

I just use dropdown menu for the year.

How to get the record...

Thank you again.

Jac

-Jax H.

Hi Jac,

I'm not entirely sure how you have your section set up. But if the year is a unique field then you could do something like this:

//Set the year data to nothing
$yearData = "";

if(@$_REQUEST['getYear']){
  //Validate the year post data
  $year = intval($_REQUEST['year']);
  //Get the record for this year.
  $yearData = mysql_get('year', null, "year = '$year'");
}

?>

<form method="post" action="scratch.php">
<input type="hidden" name="getYear" value="go" />
<!-- year drop down. -->
  <select name="year" >
   <option>2001</option>
    <option>2002</option>
    <option>2003</option>
    <option>2004</option>
    <option>2005</option>
  </select>
  <input type="submit" name="send" value="Go!" />
</form>

<!-- If the year data is returned, display it below -->
<?php if($yearData): ?>
<div id="yearBox">
<!-- you will need to change the the variables to match the field names you have used -->
  <span class="title">January</span><span><?php echo $yearData['start_jan']; ?></span><span><?php echo $yearData['finish_jan']; ?></span><br>
    <span class="title">Febuary</span><span><?php echo $yearData['start_feb']; ?></span><span><?php echo $yearData['finish_feb']; ?></span><br>
    <span class="title">March</span> <span><?php echo $yearData['start_march']; ?></span><span><?php echo $yearData['finish_march']; ?></span><br>
    <span class="title">April</span> <span><?php echo $yearData['start_apr']; ?></span><span><?php echo $yearData['finish_apr']; ?></span><br>
    <span class="title">May</span> <span><?php echo $yearData['start_may']; ?></span><span><?php echo $yearData['finish_may']; ?></span><br>
  </div>
<?php endif; ?>

The version above is based on the test year section I created for your previous question. You will probably need to change the names of the fields and sections so that they match the names you have used. 

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hi Gerg here

I would ike to create a dropdown feature ( tag) for the year field.

When choose the year. It can display the year record (12month).

How can I use tag to get record?

<?php foreach ($monthly_revenueRecords as $record): ?>
Record Number: <?php echo htmlencode($record['num']) ?><br/>

Year (value):
<select size="1" id="select" name="select">
<option><?php echo $record['year'] ?></option>
</select>

Parent: <?php echo htmlencode($record['parent_jan']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_jan']) ?><br/>
Parent: <?php echo htmlencode($record['parent_feb']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_feb']) ?><br/>
Parent: <?php echo htmlencode($record['parent_march']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_march']) ?><br/>
Parent: <?php echo htmlencode($record['parent_apr']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_apr']) ?><br/>
Parent: <?php echo htmlencode($record['parent_may']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_may']) ?><br/>
Parent: <?php echo htmlencode($record['parent_jun']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_jun']) ?><br/>
Parent: <?php echo htmlencode($record['parent_jul']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_jul']) ?><br/>
Parent: <?php echo htmlencode($record['parent_aug']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_aug']) ?><br/>
Parent: <?php echo htmlencode($record['parent_sep']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_sep']) ?><br/>
Parent: <?php echo htmlencode($record['parent_oct']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_oct']) ?><br/>
Parent: <?php echo htmlencode($record['parent_nov']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_nov']) ?><br/>
Parent: <?php echo htmlencode($record['parent_dec']) ?><br/>
Consolidated: <?php echo htmlencode($record['consolidated_dec']) ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>
<hr/>
<?php endforeach ?>

<?php if (!$monthly_revenueRecords): ?>
No records were found!<br/><br/>
<?php endif ?>



Thanks!

Jac

-Jax H.

Hi Gerg 

Got the error:

MySQL Error: Table 'quanmax_cmsAdmin.cms_year' doesn't exist (at old_alias_functions.php line 142 in function mysql_select_query)

The Table 'quanmax_cmsAdmin.cms_year' doesn't exist.

Any ideas?

Many thanks for you help!

Jac

-Jax H.

Hi Jac,

You need to change the names of the sections in the mql functions to match the names of your sections:

//Set the year data to nothing
$yearData = "";

//This array will contain all of the years used.
$yearList = array();

//This will get all the entries from the year table
$years = mysql_select('year');


//loop through the year table entries
foreach($years as $year){
//If the year isn't stored in the year list, add it!
if(!in_array($year['year'], $yearList)){
$yearList[] = $year['year'];
}
}

if(@$_REQUEST['getYear']){
//Validate the year post data
$year = intval($_REQUEST['year']);
//Get the record for this year.
$yearData = mysql_get('year', null, "year = '$year'");
}

?>

<form method="post" action="scratch.php">
<input type="hidden" name="getYear" value="go" />
<!-- year drop down. -->
<select name="year" >
<!-- loop through the year entries -->
<?php foreach($yearList as $yearEntry): ?>
<option value="<?php echo $yearEntry; ?>" ><?php echo $yearEntry; ?></option>
<?php endforeach; ?>
</select>
<input type="submit" name="send" value="Go!" />
</form>

<!-- If the year data is returned, display it below -->
<?php if($yearData): ?>
<div id="yearBox">
<!-- you will need to change the the variables to match the field names you have used -->
<span class="title">January</span><span><?php echo $yearData['start_jan']; ?></span><span><?php echo $yearData['finish_jan']; ?></span><br>
<span class="title">Febuary</span><span><?php echo $yearData['start_feb']; ?></span><span><?php echo $yearData['finish_feb']; ?></span><br>
<span class="title">March</span> <span><?php echo $yearData['start_march']; ?></span><span><?php echo $yearData['finish_march']; ?></span><br>
<span class="title">April</span> <span><?php echo $yearData['start_apr']; ?></span><span><?php echo $yearData['finish_apr']; ?></span><br>
<span class="title">May</span> <span><?php echo $yearData['start_may']; ?></span><span><?php echo $yearData['finish_may']; ?></span><br>
</div>
<?php endif; ?>

I've highlighted items you will need to change in red above. 

Greg Thomas







PHP Programmer - interactivetools.com

Hi Gerg

I try to fix the code for my page.  got error.

MySQL Error: Unknown column 'monthly_revenue' in 'where clause' (at old_alias_functions.php line 18 in function mysql_get_query)

The attachment is the file.

Can you help??

Thanks in advance for your help!

Jac

-Jax H.

Hi Jac,

I think the problem is with your mysql_get function on line 41:

$yearData = mysql_get('monthly_revenue', null, "monthly_revenue = '$year'");

The third variable for a mysql_get function is a where statement that you want to use to refine your results. In this case you want it to filter on the year field, so the function should look like this:

$yearData = mysql_get('monthly_revenue', null, "year = '$year'");

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com