On Tue, Jun 26, 2012 at 2:53 PM, Ditshwanelo <truthmal...@mailbox.co.za> wrote:
>
> Im trying to populate data from database bt isnt,im a begginer sory for a
> lame question
>
> function download()
>  {
>
>  $urlquery = $this->Newsletter->query("SELECT url,image_url,year,season FROM
> newsletters WHERE status='Active'");
>
>       foreach($urlquery as $URL)
>        {
>       //echo '<a href="/".$hyperlink."/"><img
> src="images/pdf.PNG"/><br/></a>';
>   // echo '<a href=".$hyperlink.">Newsletters<br/></a>';
>
>   //variables
>    $hyperlink=$URL['Newsletter']['url'];
>    $year=$URL['Newsletter']['year'];
>    $season = $URL['Newsletter']['season'];
>    $image_url=$URL['Newsletter']['image_url'];
>    print_r($season);
>    echo'<table width="350" border="1" cellpadding="0" cellspacing="0" >
>     <th>Year</th><th>Season</th><th>Download Newsletter</th>';
>
>      echo'<tr>';
>
>      echo"<td>$year</td>";
>       echo"<td>$season</td>";
>    echo '<td><a href=".$hyperlink."><img
> src=".$image_url."/><br/></a></td>';
>    echo'</tr>';
>
>
>
>    echo'</table>';
>
>
>        }
>      //print_r($y);
>
>     }

I think you should look again at how to query using cake. You should
look at find for a start instead of creating your own query.

Also, are you using this function in a controller, a model or a view
because there seems to be a mix of everything in there. Take the
output part at the end (the table) and put it in a view. Maybe even
the whole foreach section.

What are you seeing when you try to run this? What are your errors?

Mike.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to