By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,045 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,045 IT Pros & Developers. It's quick & easy.

How to display foreach values to tables formate or datables?

aveeva
P: 27
My foreach values like,



code :

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. session_start();
  4.  
  5. foreach($_SESSION['playlist'] as $key=>$value)
  6. {
  7.     echo $key.' '.$value.'<pre>';
  8. }
  9.  
  10. ?>
  11.  
How to display like,
Expand|Select|Wrap|Line Numbers
  1. ________________
  2. |Id   |  Title |
  3. ______|________|   
  4. |.    |    .   |
  5. |.    |    .   |
  6. |.    |    .   |
  7. |.    |    .   | 
  8. |.    |    .   |
  9. ______|________|
1 Week Ago #1
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,282
what about a html-table?
1 Week Ago #2

aveeva
P: 27
@gits Inside the PHP how can i add HTML Table?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. session_start();
  4.  
  5. foreach($_SESSION['playlist'] as $key=>$value)
  6.     {
  7.     echo $key.' '.$value.'<pre>';
  8. }
  9. ?>
  10.  
FYI : Here $key is Id & $value is Title

output :

https://snag.gy/PHmLKh.jpg
1 Week Ago #3

gits
Expert Mod 5K+
P: 5,282
html is nothing more then a string - at the moment you echo plain values - add tags to them as strings and see how it behaves. this is really basic

PS: you already doing it with a <pre> tag
1 Week Ago #4

Post your reply

Sign in to post your reply or Sign up for a free account.