Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6919085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:56:38+00:00 2026-05-27T09:56:38+00:00

I have this data spited out from my cake php query.. This is the

  • 0

I have this data spited out from my cake php query.. This is the problem.. How can i retrieve this data so that it fits this structure. How can I do this in my view?, I am just having trouble understanding how to retrieve each value

so this part I want it in a <p></p> in my page

array
  'id' => string '1' (length=1)
  'category_name' => string 'Appetizers' (length=10)
  'category_keywords' => string 'appetizer, appetizers' (length=21)
  'category_title' => string 'Our Side Dishes' (length=15)
  'category_info' => string 'Hello This is the category info' (length=30)
  'dish_id' => string '1' (length=1)

This other part returned of the query i want to put it in a 3 x 2 table. like

<table>
<tr>
 <td> the data from the array 0</td>
 <td> the data from the array 1</td>
 <td> the data from the array 2>/td>
</tr>
<tr>
 <td> the data from the array 3</td>
 <td> the data from the array 4</td>
 <td> the data from the array 5>/td>
</tr>

here are all the those arrays. I would like to use a for loop with a mod if 3 %== 0 and then create a new <tr>, i tried it but it gave me an error…

 array
  'id' => string '1' (length=1)
  'category_name' => string 'Appetizers' (length=10)
  'category_keywords' => string 'appetizer, appetizers' (length=21)
  'category_title' => string 'Our Side Dishes' (length=15)
  'category_info' => string 'Hello This is the category info' (length=441)
  'dish_id' => string '1' (length=1)

array
  0 => 
    array
      'id' => string '1' (length=1)
      'dish_name' => string 'Arepa Con Pollo!' (length=16)
      'dish_disc' => string 'Exquisite corn patti, the best yyy' (length=34)
      'dish_price' => string '2.90' (length=4)
      'dish_image' => string '/img/arepa rellena con pollo.jpeg' (length=33)
      'dish_category_id' => string '1' (length=1)
      'dish_price_label' => string 'Delicious Arepa ' (length=16)
  1 => 
    array
      'id' => string '2' (length=1)
      'dish_name' => string 'Arepa Con Queso' (length=15)
      'dish_disc' => string 'Corn patie with Cheese' (length=22)
      'dish_price' => string '2.65' (length=4)
      'dish_image' => string '/img/arepa rellena con queso.jpeg' (length=33)
      'dish_category_id' => string '1' (length=1)
      'dish_price_label' => string '' (length=0)
  2 => 
    array
      'id' => string '3' (length=1)
      'dish_name' => string 'Empanadas de Carne' (length=18)
      'dish_disc' => string 'Patties with beef' (length=17)
      'dish_price' => string '1.60' (length=4)
      'dish_image' => string '/img/empanadas de carne.jpeg' (length=28)
      'dish_category_id' => string '1' (length=1)
      'dish_price_label' => string '' (length=0)
  3 => 
    array
      'id' => string '4' (length=1)
      'dish_name' => string 'Empanadas de Pollo' (length=18)
      'dish_disc' => string 'Patties with Chicken' (length=20)
      'dish_price' => string '1.94' (length=4)
      'dish_image' => string '/img/empanadas de pollo.jpeg' (length=28)
      'dish_category_id' => string '1' (length=1)

There are more arrays besides these.. but they all have the same format.

These come from working with the following controllers

class DishCategory extends AppModel{

           public $hasMany = array(
            'Dish' => array(
                'className' => 'Dish',
                'foreignKey' => 'dish_category_id'
            )
        );

 }

class DishCategoriesController extends AppController {

 function get_categories($id)
      { 
        // find category with a dish of $id
        $this->set('dishes', $this->DishCategory->find('first', array(
          'conditions' => array(
            'DishCategory.id' => $id
          )
        )));

        // set master layout
        $this->layout = 'master_layout';
      }     
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:56:39+00:00Added an answer on May 27, 2026 at 9:56 am

    Use this->set('variableName', $data); to pass your arrays from the controller to the view.

    You can then access the example above as $variableName in your view. I would recommend doing a <?php debug($variableName); ?> first to see what your array looks like in the view. It should be the same, but it will help you know what indices to use.

    For more info: http://book.cakephp.org/view/979/set

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script that collects data from users and I want to check
I have an XML file which describes the data-structure that I can exchange on
I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have this Javascript data: [{id:123,type:test},{id:154,type:another}] How would you transform that into something so
We have this set of data that we need to get the average of
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
Say I have this table schema. ID AccNo Amount Say I have this data
I have this big data-entry sort of page, a table kind of layout using
I have this scenario where I need data integrity in the physical database. For
we have this scenario: A server which contains needed data and client component which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.