Saturday, November 13, 2010

cakePHP and database help!

I'm building a database of solar system for a course.
Here's what I have problem with:


I have a 'regularplanet' model which has 'regularplanets' controller.
When I go to /htdocs/solar/regularplanets, my page lists all the
planets (Earth, Venus, etc.). Beside every planet I want to have a
link 'Attribute' which goes to another page /htdocs/solar/
regularplanets/attribute which displays the attributes (Mass, Age,
Revolution time, etc) corresponding to that planet.

Now here is the problem. I have a function Attribute created in the
Regularplanets controller which has a parameter ($Name). From what I
understand, when a user clicks on the 'Attribute' beside Earth it
should pass 'Earth' as the name in the attribute function in the
controller. But, this is not happening in my program. How do I make
Cake know that when a link for Earth attribute is clicked, it should
pass Earth as Name in the controller and should output its attributes.

This is what I have as a link for Attributes in my index.ctp file.
[code] <?php echo $this->Html->link('Attributes', array('action' =>
'Attribute') ); ?>[/code]

Please let me know if someone is still confused about what I'm talking
about here. I'll try to upload images and explain better.
Thanks.

This is how my index.ctp looks like:
[code]

<table>
<th> Name </th>


<?php foreach ($regularplanets as $regularplanet): ?>
<tr>

<td> <?php echo $regularplanet['Regularplanet']['Name']; ?> </td>

<td> <?php echo $this->Html->link('Attributes', array('action' =>
'Attribute') ); ?></td>

</tr>

<?php endforeach; ?>

</table>

[/code]

Also I have this in my controller:
[code]
function attribute ($Name){
$this->Regularplanet->Name = $Name;
$this->set('regularplanet', $this->Regularplanet->read());
}
[/code]

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate