Tuesday, June 2, 2009

Re: echo table contents

In the view:

<table>
<?php
foreach( $products as $product ) {
echo '<tr>';
echo '<td>'.$product['Product']['name'].'</td>';
// echo more fields here
echo '</tr>';

}
?>
</table>

That will output a basic table of products and the data you want to
present.

On Jun 2, 1:29 am, dflow <deeepf...@gmail.com> wrote:
> starting off cakephp
> how do you echo a simple mysql query  for example
>
> i created the product models, the products_controller and the /product/
> index.ctp view
>
> which function echos the content of a table
>
> <?php
> class ProductsController extends AppController {
>         var $name = 'Products';
>         var $uses = array('Products', 'Product');
>
>         function index() {
>                 $this->set('products', $this->Product->find('all'));
>         }
>
> }
>
> ?>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

No comments: