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;
  }

```

}
**N.B.** `explode()` function breaks the string into array, it accepts three arguments, first one is the delimiter that specifies where to break the string, second one is the string that needs splitting, and third one is not mandatory but it tells how many array to return.

```
$str_to_exploade = 'This,string,needs,some,exploiting';
$explode_string = explode(',', $str_to_exploade);
echo '<pre>';
print_r($explode_string);
echo $explode_string[0].'<br/>';
echo $explode_string[1];

```

More about explode() go to : <http://php.net/manual/en/function.explode.php>