Q:

How to display multiple rows of comma separated values from mysql db

I need your help with display of some comma separated enteries from my database.
My main table schema looks like this
              |---|----------|-----------|----------------------------|
              |id | tab1     |  tab2     |          tab3              | 
              |---|----------|-----------|----------------------------|
              |1  |  state1  |  A-North  |   constA1,constA2,constA3  |
              |2  |  state2  |  B-South  |   constB1,constB2,constB3  |
              ---------------------------------------------------------

Query I'm trying to make work
$query = mysql_query("SELECT * FROM `main` WHERE `tab1` = '$tab1'") 
         or die(mysql_error());

while($row=mysql_fetch_array($query)){                  
  $tab3 = explode(",", $row['tab3']);
  echo $tab3."<br>";
}       

What I want to display from the database                   
               A-North      B-South
               ---------------------                   
               constA1      constB1
               constA2      constB2
               constA3      constB3

Error I'm getting  when I run that query is  "Array" . When I run the same code from phpMyAdmin, I get the desired rows (result).

A:

Explode gives you the results in an array so you'll want another loop that runs through the $tab3 array printing the result. See the definition from the PHP manual:

Returns an array of strings, each of which is a substring of string
  formed by splitting it on boundaries formed by the string delimiter.

For example:
for ($i = 0; $i < sizeof($tab3); $i++) {
    echo $tab3[$i].'<br />';
}

