How to explode comma separated arrays from databaseDeleting an element from an array in PHPHow do I get a YouTube video thumbnail from the YouTube API?Reference — What does this symbol mean in PHP?How to pass an array within a query string?PHP: how to combine foreach and explodeExplode and then merge arraysArray to comma separated stringsPhp build array from comma separated array valuesHow to convert comma separated string to key value array in phpGet rows from Database from comma-separated value
For the erase-remove idiom, why is the second parameter necessary which points to the end of the container?
How did Thanos not realise this had happened at the end of Endgame?
How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?
51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?
Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?
A curve pass via points at TiKz
How are one-time password generators like Google Authenticator different from having two passwords?
Why does the Earth follow an elliptical trajectory rather than a parabolic one?
On studying Computer Science vs. Software Engineering to become a proficient coder
What are the implications of the new alleged key recovery attack preprint on SIMON?
How can this pool heater gas line be disconnected?
Front derailleur hard to move due to gear cable angle
SSD - Disk is OK, one bad sector
Why does getw return -1 when trying to read a character?
How does Howard Stark know this?
Why do Thanos's punches not kill Captain America or at least cause some mortal injuries?
Is the schwa sound consistent?
Drawing lines to nearest point
Can I make ravioli dough with only all-purpose flour or do I NEED semolina flour?
Meaning of「〜てみたいと思います」
What is the best way for a skeleton to impersonate human without using magic?
What is Plautus’s pun about frustum and frustrum?
What does i386 mean on macOS Mojave?
tikz: not so precise graphic
How to explode comma separated arrays from database
Deleting an element from an array in PHPHow do I get a YouTube video thumbnail from the YouTube API?Reference — What does this symbol mean in PHP?How to pass an array within a query string?PHP: how to combine foreach and explodeExplode and then merge arraysArray to comma separated stringsPhp build array from comma separated array valuesHow to convert comma separated string to key value array in phpGet rows from Database from comma-separated value
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:
---------------
Product Name
---------------
Product 1
Product 2
Product 3
But i am getting array to string conversion error.
<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>
So, how can i explode and fetch the data in codeigniter
php codeigniter
add a comment |
I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:
---------------
Product Name
---------------
Product 1
Product 2
Product 3
But i am getting array to string conversion error.
<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>
So, how can i explode and fetch the data in codeigniter
php codeigniter
are you facing any error?
– M.Hemant
Mar 23 at 11:58
echo explode(',',$prodArray)
this line is just wrong. You can't echo an array like this.
– Eduardo Junior
Mar 23 at 12:02
Please, post a $res array format example.
– Eduardo Junior
Mar 23 at 12:03
You can convert an array to a string:$arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;
– Jamie_D
Mar 23 at 12:23
add a comment |
I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:
---------------
Product Name
---------------
Product 1
Product 2
Product 3
But i am getting array to string conversion error.
<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>
So, how can i explode and fetch the data in codeigniter
php codeigniter
I am unable to explode comma separated data array from the database in codeigniter framework. I want to echo the array into multiple rows with string value like:
---------------
Product Name
---------------
Product 1
Product 2
Product 3
But i am getting array to string conversion error.
<?php foreach ($res as $key => $value) ?>
<tr class="border-bottom">
<td>
<?php $prodArray = $value->product;
echo explode(',',$prodArray) ?>
</td>
</tr>
<?php ?>
So, how can i explode and fetch the data in codeigniter
php codeigniter
php codeigniter
asked Mar 23 at 11:56
Muhammad AhtshamMuhammad Ahtsham
21
21
are you facing any error?
– M.Hemant
Mar 23 at 11:58
echo explode(',',$prodArray)
this line is just wrong. You can't echo an array like this.
– Eduardo Junior
Mar 23 at 12:02
Please, post a $res array format example.
– Eduardo Junior
Mar 23 at 12:03
You can convert an array to a string:$arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;
– Jamie_D
Mar 23 at 12:23
add a comment |
are you facing any error?
– M.Hemant
Mar 23 at 11:58
echo explode(',',$prodArray)
this line is just wrong. You can't echo an array like this.
– Eduardo Junior
Mar 23 at 12:02
Please, post a $res array format example.
– Eduardo Junior
Mar 23 at 12:03
You can convert an array to a string:$arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;
– Jamie_D
Mar 23 at 12:23
are you facing any error?
– M.Hemant
Mar 23 at 11:58
are you facing any error?
– M.Hemant
Mar 23 at 11:58
echo explode(',',$prodArray)
this line is just wrong. You can't echo an array like this.– Eduardo Junior
Mar 23 at 12:02
echo explode(',',$prodArray)
this line is just wrong. You can't echo an array like this.– Eduardo Junior
Mar 23 at 12:02
Please, post a $res array format example.
– Eduardo Junior
Mar 23 at 12:03
Please, post a $res array format example.
– Eduardo Junior
Mar 23 at 12:03
You can convert an array to a string:
$arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;
– Jamie_D
Mar 23 at 12:23
You can convert an array to a string:
$arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;
– Jamie_D
Mar 23 at 12:23
add a comment |
2 Answers
2
active
oldest
votes
VIEW FILE
<table>
<th>
<td>S. NO</td>
<td>Product Name</td>
</th>
<tbody>
<?php
$no = 1;
foreach($products as $product)
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $product->product_name;?></td> //update with your column name
</tr>
<?php
$no++;
?>
</tbody>
</table>
MODEL FILE
public function get_products()
$this->db->select('*');
$this->db->from('products_table'); //update with your table name
return $this->db->get()->result_object(); // sucess result or handle exceptiom here
CONTROLLER FILE
public function product()
$this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
$this->products = $this->product->get_products();
$this->load->view('products_view');
add a comment |
<?php foreach ($res as $key => $value)
$prodArray = $value->product;
if($prodArray) foreach($prodArray as $product)
?>
<tr class="border-bottom">
<td>
<?php echo $product; ?>
</td>
</tr>
<?php ?>
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313476%2fhow-to-explode-comma-separated-arrays-from-database%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
VIEW FILE
<table>
<th>
<td>S. NO</td>
<td>Product Name</td>
</th>
<tbody>
<?php
$no = 1;
foreach($products as $product)
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $product->product_name;?></td> //update with your column name
</tr>
<?php
$no++;
?>
</tbody>
</table>
MODEL FILE
public function get_products()
$this->db->select('*');
$this->db->from('products_table'); //update with your table name
return $this->db->get()->result_object(); // sucess result or handle exceptiom here
CONTROLLER FILE
public function product()
$this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
$this->products = $this->product->get_products();
$this->load->view('products_view');
add a comment |
VIEW FILE
<table>
<th>
<td>S. NO</td>
<td>Product Name</td>
</th>
<tbody>
<?php
$no = 1;
foreach($products as $product)
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $product->product_name;?></td> //update with your column name
</tr>
<?php
$no++;
?>
</tbody>
</table>
MODEL FILE
public function get_products()
$this->db->select('*');
$this->db->from('products_table'); //update with your table name
return $this->db->get()->result_object(); // sucess result or handle exceptiom here
CONTROLLER FILE
public function product()
$this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
$this->products = $this->product->get_products();
$this->load->view('products_view');
add a comment |
VIEW FILE
<table>
<th>
<td>S. NO</td>
<td>Product Name</td>
</th>
<tbody>
<?php
$no = 1;
foreach($products as $product)
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $product->product_name;?></td> //update with your column name
</tr>
<?php
$no++;
?>
</tbody>
</table>
MODEL FILE
public function get_products()
$this->db->select('*');
$this->db->from('products_table'); //update with your table name
return $this->db->get()->result_object(); // sucess result or handle exceptiom here
CONTROLLER FILE
public function product()
$this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
$this->products = $this->product->get_products();
$this->load->view('products_view');
VIEW FILE
<table>
<th>
<td>S. NO</td>
<td>Product Name</td>
</th>
<tbody>
<?php
$no = 1;
foreach($products as $product)
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $product->product_name;?></td> //update with your column name
</tr>
<?php
$no++;
?>
</tbody>
</table>
MODEL FILE
public function get_products()
$this->db->select('*');
$this->db->from('products_table'); //update with your table name
return $this->db->get()->result_object(); // sucess result or handle exceptiom here
CONTROLLER FILE
public function product()
$this->load->model('product'); // can be loaded in the parent::__construct(); at the begining of the controller
$this->products = $this->product->get_products();
$this->load->view('products_view');
answered Mar 23 at 12:22
KrishnaKrishna
414
414
add a comment |
add a comment |
<?php foreach ($res as $key => $value)
$prodArray = $value->product;
if($prodArray) foreach($prodArray as $product)
?>
<tr class="border-bottom">
<td>
<?php echo $product; ?>
</td>
</tr>
<?php ?>
add a comment |
<?php foreach ($res as $key => $value)
$prodArray = $value->product;
if($prodArray) foreach($prodArray as $product)
?>
<tr class="border-bottom">
<td>
<?php echo $product; ?>
</td>
</tr>
<?php ?>
add a comment |
<?php foreach ($res as $key => $value)
$prodArray = $value->product;
if($prodArray) foreach($prodArray as $product)
?>
<tr class="border-bottom">
<td>
<?php echo $product; ?>
</td>
</tr>
<?php ?>
<?php foreach ($res as $key => $value)
$prodArray = $value->product;
if($prodArray) foreach($prodArray as $product)
?>
<tr class="border-bottom">
<td>
<?php echo $product; ?>
</td>
</tr>
<?php ?>
answered Mar 23 at 13:10
Harshwardhan SharmaHarshwardhan Sharma
1459
1459
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313476%2fhow-to-explode-comma-separated-arrays-from-database%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
are you facing any error?
– M.Hemant
Mar 23 at 11:58
echo explode(',',$prodArray)
this line is just wrong. You can't echo an array like this.– Eduardo Junior
Mar 23 at 12:02
Please, post a $res array format example.
– Eduardo Junior
Mar 23 at 12:03
You can convert an array to a string:
$arrStr = print_r(explode(',',$prodArray), true); echo $arrStr;
– Jamie_D
Mar 23 at 12:23