Concep of c# Dictionary in PHP Codeigniter Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to merge two dictionaries in a single expression?How can I prevent SQL injection in PHP?How do I sort a list of dictionaries by a value of the dictionary?What is the best way to iterate over a dictionary?PHP: Delete an element from an arrayHow do I sort a dictionary by value?Add new keys to a dictionary?Check if a given key already exists in a dictionaryIterating over dictionaries using 'for' loopsReference — What does this symbol mean in PHP?

NERDTreeMenu Remapping

How can a team of shapeshifters communicate?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Why is std::move not [[nodiscard]] in C++20?

Why is it faster to reheat something than it is to cook it?

Relating to the President and obstruction, were Mueller's conclusions preordained?

Did any compiler fully use 80-bit floating point?

How to ask rejected full-time candidates to apply to teach individual courses?

How many time has Arya actually used Needle?

Test print coming out spongy

Google .dev domain strangely redirects to https

Can an iPhone 7 be made to function as a NFC Tag?

Co-worker has annoying ringtone

Why complex landing gears are used instead of simple,reliability and light weight muscle wire or shape memory alloys?

Does the Mueller report show a conspiracy between Russia and the Trump Campaign?

A `coordinate` command ignored

White walkers, cemeteries and wights

In musical terms, what properties are varied by the human voice to produce different words / syllables?

A proverb that is used to imply that you have unexpectedly faced a big problem

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

How to force a browser when connecting to a specific domain to be https only using only the client machine?

Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?

How do living politicians protect their readily obtainable signatures from misuse?

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?



Concep of c# Dictionary in PHP Codeigniter



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to merge two dictionaries in a single expression?How can I prevent SQL injection in PHP?How do I sort a list of dictionaries by a value of the dictionary?What is the best way to iterate over a dictionary?PHP: Delete an element from an arrayHow do I sort a dictionary by value?Add new keys to a dictionary?Check if a given key already exists in a dictionaryIterating over dictionaries using 'for' loopsReference — What does this symbol mean in PHP?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm trying to implement the concept of dictionary which i use in c# in order to collect multiple records based on multiple id's. But i hardly find any such thing in codeigniter framework. What I have is a Course table and another table naming course_prices. Now each course has multiple prices. And I'm trying to display using bootstrap according having course name as title of header accordion and list of prices on the content div.



As i couldn't find the concept of dictionary here, i tried with writing join query but that wouldn't help. The details of courses are repeated.



Below is my code



$this->load->model('Courses_model', 'Courses');

$model = $this->Courses;

$records = $model->setAlias('c')
->find()
->select('c.*,cp.Id as PriceId')
->join('course_price AS cp', 'c.id = cp.CourseId')
->get()
->result_array();


And this is the view



<?php if(empty($courses)) print_r("no class available"); else{ print_r($courses); foreach ($courses as $k => $course) ?>

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?=$k?>">
<h4 class="panel-title">
<a class="" role="button" data-toggle="collapse" data-parent="#accordion9" href="#collapse<?=$k?>" aria-expanded="true" aria-controls="collapseOne9">
<?= $course->name ?>
</a>
</h4>
</div>
<div id="collapse<?=$k?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?=$k?>">
<div class="panel-body">

<?php foreach ($course->course_price as $key => $price) ?>
<div class="custom-controls-stacked">
<div class="custom-control custom-radio">
<input name="class" id="class_1<?= $k ?>" type="radio" class="custom-control-input" value="<?= $price->PriceId; ?>" required>
<label for="class_<?= $k ?>" class="custom-control-label">Drop In Price <?= $course->price ?></label>
</div>
</div>

</div>
</div>
</div>
<?php ?>


enter image description here










share|improve this question
























  • The C#'s concept for Dictionnary is similar to what's named a Map in other languages, isn't it? If so, you could use the PHP's array. The array is a mix between array, vector and map.

    – AnthonyB
    Mar 22 at 11:25











  • We (PHP people) just call them arrays with string keys, lol. or Associative arrays.

    – ArtisticPhoenix
    Mar 22 at 11:26












  • So PHP coders, how do i apply the above scenario using Associative arrays or array mapping?

    – Salar Muhammad
    Mar 22 at 11:28











  • <?= $course->name ?> might want some semi-colons there.... And these ID's will probably be duplicate id="class_1<?= $k ?>" $k is the key of the outer loop the one over $courses that I almost didn't see. So when you loop with the inner loop $k doesn't change.

    – ArtisticPhoenix
    Mar 22 at 11:29












  • @ArtisticPhoenix Good eye :)

    – Salar Muhammad
    Mar 22 at 11:31

















1















I'm trying to implement the concept of dictionary which i use in c# in order to collect multiple records based on multiple id's. But i hardly find any such thing in codeigniter framework. What I have is a Course table and another table naming course_prices. Now each course has multiple prices. And I'm trying to display using bootstrap according having course name as title of header accordion and list of prices on the content div.



As i couldn't find the concept of dictionary here, i tried with writing join query but that wouldn't help. The details of courses are repeated.



Below is my code



$this->load->model('Courses_model', 'Courses');

$model = $this->Courses;

$records = $model->setAlias('c')
->find()
->select('c.*,cp.Id as PriceId')
->join('course_price AS cp', 'c.id = cp.CourseId')
->get()
->result_array();


And this is the view



<?php if(empty($courses)) print_r("no class available"); else{ print_r($courses); foreach ($courses as $k => $course) ?>

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?=$k?>">
<h4 class="panel-title">
<a class="" role="button" data-toggle="collapse" data-parent="#accordion9" href="#collapse<?=$k?>" aria-expanded="true" aria-controls="collapseOne9">
<?= $course->name ?>
</a>
</h4>
</div>
<div id="collapse<?=$k?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?=$k?>">
<div class="panel-body">

<?php foreach ($course->course_price as $key => $price) ?>
<div class="custom-controls-stacked">
<div class="custom-control custom-radio">
<input name="class" id="class_1<?= $k ?>" type="radio" class="custom-control-input" value="<?= $price->PriceId; ?>" required>
<label for="class_<?= $k ?>" class="custom-control-label">Drop In Price <?= $course->price ?></label>
</div>
</div>

</div>
</div>
</div>
<?php ?>


enter image description here










share|improve this question
























  • The C#'s concept for Dictionnary is similar to what's named a Map in other languages, isn't it? If so, you could use the PHP's array. The array is a mix between array, vector and map.

    – AnthonyB
    Mar 22 at 11:25











  • We (PHP people) just call them arrays with string keys, lol. or Associative arrays.

    – ArtisticPhoenix
    Mar 22 at 11:26












  • So PHP coders, how do i apply the above scenario using Associative arrays or array mapping?

    – Salar Muhammad
    Mar 22 at 11:28











  • <?= $course->name ?> might want some semi-colons there.... And these ID's will probably be duplicate id="class_1<?= $k ?>" $k is the key of the outer loop the one over $courses that I almost didn't see. So when you loop with the inner loop $k doesn't change.

    – ArtisticPhoenix
    Mar 22 at 11:29












  • @ArtisticPhoenix Good eye :)

    – Salar Muhammad
    Mar 22 at 11:31













1












1








1








I'm trying to implement the concept of dictionary which i use in c# in order to collect multiple records based on multiple id's. But i hardly find any such thing in codeigniter framework. What I have is a Course table and another table naming course_prices. Now each course has multiple prices. And I'm trying to display using bootstrap according having course name as title of header accordion and list of prices on the content div.



As i couldn't find the concept of dictionary here, i tried with writing join query but that wouldn't help. The details of courses are repeated.



Below is my code



$this->load->model('Courses_model', 'Courses');

$model = $this->Courses;

$records = $model->setAlias('c')
->find()
->select('c.*,cp.Id as PriceId')
->join('course_price AS cp', 'c.id = cp.CourseId')
->get()
->result_array();


And this is the view



<?php if(empty($courses)) print_r("no class available"); else{ print_r($courses); foreach ($courses as $k => $course) ?>

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?=$k?>">
<h4 class="panel-title">
<a class="" role="button" data-toggle="collapse" data-parent="#accordion9" href="#collapse<?=$k?>" aria-expanded="true" aria-controls="collapseOne9">
<?= $course->name ?>
</a>
</h4>
</div>
<div id="collapse<?=$k?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?=$k?>">
<div class="panel-body">

<?php foreach ($course->course_price as $key => $price) ?>
<div class="custom-controls-stacked">
<div class="custom-control custom-radio">
<input name="class" id="class_1<?= $k ?>" type="radio" class="custom-control-input" value="<?= $price->PriceId; ?>" required>
<label for="class_<?= $k ?>" class="custom-control-label">Drop In Price <?= $course->price ?></label>
</div>
</div>

</div>
</div>
</div>
<?php ?>


enter image description here










share|improve this question
















I'm trying to implement the concept of dictionary which i use in c# in order to collect multiple records based on multiple id's. But i hardly find any such thing in codeigniter framework. What I have is a Course table and another table naming course_prices. Now each course has multiple prices. And I'm trying to display using bootstrap according having course name as title of header accordion and list of prices on the content div.



As i couldn't find the concept of dictionary here, i tried with writing join query but that wouldn't help. The details of courses are repeated.



Below is my code



$this->load->model('Courses_model', 'Courses');

$model = $this->Courses;

$records = $model->setAlias('c')
->find()
->select('c.*,cp.Id as PriceId')
->join('course_price AS cp', 'c.id = cp.CourseId')
->get()
->result_array();


And this is the view



<?php if(empty($courses)) print_r("no class available"); else{ print_r($courses); foreach ($courses as $k => $course) ?>

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?=$k?>">
<h4 class="panel-title">
<a class="" role="button" data-toggle="collapse" data-parent="#accordion9" href="#collapse<?=$k?>" aria-expanded="true" aria-controls="collapseOne9">
<?= $course->name ?>
</a>
</h4>
</div>
<div id="collapse<?=$k?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?=$k?>">
<div class="panel-body">

<?php foreach ($course->course_price as $key => $price) ?>
<div class="custom-controls-stacked">
<div class="custom-control custom-radio">
<input name="class" id="class_1<?= $k ?>" type="radio" class="custom-control-input" value="<?= $price->PriceId; ?>" required>
<label for="class_<?= $k ?>" class="custom-control-label">Drop In Price <?= $course->price ?></label>
</div>
</div>

</div>
</div>
</div>
<?php ?>


enter image description here







php codeigniter dictionary






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 11:53







Salar Muhammad

















asked Mar 22 at 11:17









Salar MuhammadSalar Muhammad

85211




85211












  • The C#'s concept for Dictionnary is similar to what's named a Map in other languages, isn't it? If so, you could use the PHP's array. The array is a mix between array, vector and map.

    – AnthonyB
    Mar 22 at 11:25











  • We (PHP people) just call them arrays with string keys, lol. or Associative arrays.

    – ArtisticPhoenix
    Mar 22 at 11:26












  • So PHP coders, how do i apply the above scenario using Associative arrays or array mapping?

    – Salar Muhammad
    Mar 22 at 11:28











  • <?= $course->name ?> might want some semi-colons there.... And these ID's will probably be duplicate id="class_1<?= $k ?>" $k is the key of the outer loop the one over $courses that I almost didn't see. So when you loop with the inner loop $k doesn't change.

    – ArtisticPhoenix
    Mar 22 at 11:29












  • @ArtisticPhoenix Good eye :)

    – Salar Muhammad
    Mar 22 at 11:31

















  • The C#'s concept for Dictionnary is similar to what's named a Map in other languages, isn't it? If so, you could use the PHP's array. The array is a mix between array, vector and map.

    – AnthonyB
    Mar 22 at 11:25











  • We (PHP people) just call them arrays with string keys, lol. or Associative arrays.

    – ArtisticPhoenix
    Mar 22 at 11:26












  • So PHP coders, how do i apply the above scenario using Associative arrays or array mapping?

    – Salar Muhammad
    Mar 22 at 11:28











  • <?= $course->name ?> might want some semi-colons there.... And these ID's will probably be duplicate id="class_1<?= $k ?>" $k is the key of the outer loop the one over $courses that I almost didn't see. So when you loop with the inner loop $k doesn't change.

    – ArtisticPhoenix
    Mar 22 at 11:29












  • @ArtisticPhoenix Good eye :)

    – Salar Muhammad
    Mar 22 at 11:31
















The C#'s concept for Dictionnary is similar to what's named a Map in other languages, isn't it? If so, you could use the PHP's array. The array is a mix between array, vector and map.

– AnthonyB
Mar 22 at 11:25





The C#'s concept for Dictionnary is similar to what's named a Map in other languages, isn't it? If so, you could use the PHP's array. The array is a mix between array, vector and map.

– AnthonyB
Mar 22 at 11:25













We (PHP people) just call them arrays with string keys, lol. or Associative arrays.

– ArtisticPhoenix
Mar 22 at 11:26






We (PHP people) just call them arrays with string keys, lol. or Associative arrays.

– ArtisticPhoenix
Mar 22 at 11:26














So PHP coders, how do i apply the above scenario using Associative arrays or array mapping?

– Salar Muhammad
Mar 22 at 11:28





So PHP coders, how do i apply the above scenario using Associative arrays or array mapping?

– Salar Muhammad
Mar 22 at 11:28













<?= $course->name ?> might want some semi-colons there.... And these ID's will probably be duplicate id="class_1<?= $k ?>" $k is the key of the outer loop the one over $courses that I almost didn't see. So when you loop with the inner loop $k doesn't change.

– ArtisticPhoenix
Mar 22 at 11:29






<?= $course->name ?> might want some semi-colons there.... And these ID's will probably be duplicate id="class_1<?= $k ?>" $k is the key of the outer loop the one over $courses that I almost didn't see. So when you loop with the inner loop $k doesn't change.

– ArtisticPhoenix
Mar 22 at 11:29














@ArtisticPhoenix Good eye :)

– Salar Muhammad
Mar 22 at 11:31





@ArtisticPhoenix Good eye :)

– Salar Muhammad
Mar 22 at 11:31












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55298477%2fconcep-of-c-sharp-dictionary-in-php-codeigniter%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55298477%2fconcep-of-c-sharp-dictionary-in-php-codeigniter%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현