Hello,
I'm new with cakeph and I have a little problem:
I try a little own code:
I have three main databases which are important for these problem. I
created the models, tables and controllers.
databases:
- one with petrol stations (petrol_station_master)
- one with petrol types (Petrol_Type_Master) and
- one with petrol prices per petrol types (Petrol_Price_Master)
I created a View "Benzinrechner". The user has to possibility to add
his average petrol consumption per 100km, his kilometers per year, his
petrol type and his country.
The controller selects the price in Petrol_price_master in these
country with these petrol type and calculate the average price.
Than it multiplied the averagde price with the consumption and the
kilometers per year to costs per anno.
And a least it has to print the costs in the view.
I tried it with these Code, but it doesn't run:
----------------------------------------
View:
----------------------------------------
<?php echo __('Compare Fuel Prices', True); ?>
<p><?php echo __('Compare your kind of fuel in your city
or postcode.', True).'</p>'; ?>
<table>
<tr>
<td><br><p><?php echo __('consumption', true) ?></p></td>
<td><br><?php echo $form->input("verbrauch", array('label'
=> '','size'=>15,'id'=>'verbrauch')); ?></td>
</tr>
<tr>
<td><br><p><?php echo __('kilometers per anno', true) ?></
p></td>
<td><br><?php echo $form->input("km", array('label' =>
'','size'=>15,'id'=>'km')); ?></td>
</tr>
<tr>
<td><p><?php echo __('Fuel', true) ?></p></td>
<td><?php echo $form->select('k', $petroltypemasters,
'1'); ?></td>
</tr>
<tr>
<td><p><?php echo __('country', True); ?></p></td>
<td>
<?php
$options = array('DE' => __('Deutschland',true), 'OES' =>
__('Österreich',true), 'CH' => __('Schweiz',true));
echo $form->select('land', $options, 'DE');
?></td>
</tr>
<tr>
<td colspan=2 align=center>
<p align=center><?php echo $form->submit(__('search.gif',
true)); ?></p>
</td>
<td colspan=2><?php echo $post['average']['preis']; ?></
td>
</tr>
</table>
----------------------------------------
petrol_price_master_controller:
----------------------------------------
<?php
class PetrolPriceMastersController extends AppController {
var $helpers = array('Html', 'Form','Demo','Number');
var $name = 'PetrolPriceMasters';
var $uses = array('User',
'PetrolPriceMaster','PetrolStationMaster','PetrolTypeMaster','PetrolStationMasterToPetrolTypeMaster');
function benzinrechner($km=null, $verbrauch=null, $k=null, $land=null)
{
if (!empty($this->data)) {
$petroltypemasters = $this->PetrolStationMaster-
>PetrolTypeMaster->find('list', array('fields' => array('id',
'Petrol_Type')));
$this->set(compact('petroltypemasters'));
$average = $this->PetrolPriceMaster->query('SELECT AVG(price) AS
preis FROM petrol_price_masters WHERE petrol_type_master_id = '.$this-
>data['PetrolPriceMaster']['k'].' AND publish = 1');
$preis = $preis * $km * $verbrauch *1/100;
$this->set(compact('preis'));
}
if (empty($this->data)) {
$petroltypemasters = $this->PetrolStationMaster-
>PetrolTypeMaster->find('list', array('fields' => array('id',
'Petrol_Type')));
$this->set(compact('petroltypemasters'));
}
}
// other functions
...
----------------------------------------
Thank you very much.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php