Question: In my database table there is a column named 'marks' . it contains values like 50,55,67,88,...
Now I need to read this values one by one like - first 50, then 55 and so on. How is it possible using php ? 

```
include("db_connect.php"); 
   $result = mysql_query("SELECT * FROM  students   ",$con);
   while($rows = mysql_fetch_array($result))
{
   $mark1=$rows['marks'];//what will do here
   $mark2=$rows['marks']; //should get value 55 and so on
}

```

Answer: 
Explode the data from the database. Use the [`explode`](http://php.net/manual/en/function.explode.php) function.

Access using indexes

```
while($rows = mysql_fetch_array($result)) {
  $marks = $row['marks']; //get value of marks from the database       
  $exp = explode("," , $marks); //explode marks data

  $mark1 = $exp[0]; //result is 50
  $mark2 = $exp[1]; //result is 55
  $mark3 = $exp[3]; //result is 67
}

```

Or loop using foreach

```
while($rows = mysql_fetch_array($result)) {
  $marks = $row['marks']; //get value of marks from the database
  $exp = explode("," , $marks); //explode marks data

  foreach($exp as $mark) {
    echo $mark;
  }

```

}
If that row contains `,`, the just use `explode()`:

```
while($rows = mysql_fetch_assoc($result)) {
    $mark1 = explode(',', $rows['marks']); // should contain the comma separated values
    // in array form
    // then loop again
    foreach($mark1 as $mark_piece) {
        // do something here
    }
}

```