title: fetching and displaying data with CakePHP 2.x
body: <p>EDIT: 2. I have resolved the issue! To see the final version, look at this pastebin and see the difference between it and my code here on StackOverflow.</p>
  
  <p><a href="http://pastebin.com/yWqs86Zt" rel="nofollow noreferrer">http://pastebin.com/yWqs86Zt</a></p>
  
  <p>EDIT. I now am able to print the data on screen but I am seeing all the planet data when I only want a row per ctp. (earth row on the earth.ctp etc).</p>
  
  <p>New to cake and very much confused. I have looked over the documents but am still at a loss. Big props to anyone who can help a student developer out.</p>
  
  <p>In all I am working on an application which shows data on each planet and moon in the solar system, passing varchars of data from the Database to the whateverplanet.ctp.</p>
  
  <p>I am trying to display a row per ctp. Such as earth info on Planets/earth.ctp by calling the planet_name/info/content columns in the PlanetsController earth() function.</p>
  
  <p>I have a database with two tables</p>
  
  <ul>
  <li>planets table
  
  <ul>
  <li>planet_id (int)</li>
  <li>planet_name (varchar)</li>
  <li>planet_info (varchar)</li>
  <li>planet_content (varchar)</li>
  </ul></li>
  </ul>
  
  <p>And a moons table with the same set up just with moons instead of planets.</p>
  
  <p>Planet Model looks like</p>
  
  <pre><code>&lt;?php
  App::uses('AppModel', 'Model'); 
  class Planet extends AppModel {
  
          public $name = 'Planet';
          public $useTable = 'planets';
  } 
  
  ?&gt;
  </code></pre>
  
  <p>Controller is as this (with commented out attempts)</p>
  
  <pre><code>&lt;?php
  
  class PlanetsController extends AppController
  {
      public $name = 'Planets';
      public $helpers = array('Html', 'Form');
  
      public function earth() {
  
           $this-&gt;set('planets', $this-&gt;Planet-&gt;find('all'));
  
      }
  }
  ?&gt;
  </code></pre>
  
  <p>earth.ctp looks like this 
     </p>
  
  <pre><code>    &lt;?php echo $this-&gt;Html-&gt;image('earth1.jpg'); ?&gt;
  
      &lt;h2&gt; Fact File &lt;/h2&gt;
      &lt;?php foreach ($planets as $planet): ?&gt;
  
              &lt;h3&gt;&lt;?php echo $planet['Planet']['planet_name']; ?&gt;&lt;/h3&gt;
  
              &lt;p&gt; &lt;?php echo $planet['Planet']['planet_info']; ?&gt;&lt;/p&gt;
  
  
              &lt;?php endforeach; ?&gt;
      &lt;!--&lt;p&gt;orem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus elementum mattis turpis id aliquam. Duis vitae magna in justo varius dapibus. Donec mattis nunc tellus, at sollicitudin risus rutrum in. Curabitur vehicula et ipsum vel fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum venenatis eros gravida nibh eleifend egestas. Quisque vel libero convallis, vulputate sem nec, sollicitudin nisl. Nullam egestas orci eget velit hendrerit rhoncus.&lt;/p&gt;--&gt;
  &lt;/div&gt;&lt;!-- /.col-xs-12 main --&gt;
  </code></pre>