I want to add the username that select an item to my db . for example if three users selected that item i want it to be like user1,user2,user3 .. im getting the different users to go into db but i cant get the comma to separate .. im using explode but still not working properly
<?php
session_start();
$date = date("Y-m-d H:i:s");
include("php/connect.php");
if (isset($_SESSION['username'])){
           $query1 = mysql_query("SELECT * FROM user WHERE username='$username'");
    $username = $_SESSION['username'];
    $submit = $_POST["submit"];
    $tests = $_POST["test"];
    // If the user submitted the form.
    // Do the updating on the database.
    if (!empty($submit))
    {
        if (count($tests) > 0)
        {
            foreach ($tests as $test_id => $test_value)
            {
                switch ($test_value)
                {
                    case 1:
                        mysql_query("UPDATE test SET win = win + 1 WHERE id = '$test_id'");
                        mysql_query("UPDATE test SET date = '$date'  WHERE id = '$test_id'");
                        $username = explode(",", $username);
                        $cnt = count($username);
                        $slice = array_slice($username, 0,10);
                        mysql_query("UPDATE test SET users = CONCAT(users, '$username')  WHERE id = '$test_id'");
                    break;
                    case 'X':
                        mysql_query("UPDATE test SET draw = draw + 1 WHERE id = '$test_id'");
                        mysql_query("UPDATE test SET date = '$date'  WHERE id = '$test_id'");
                    break;
                    case 2:
                        mysql_query("UPDATE test SET lose = lose + 1 WHERE id = '$test_id'");
                        mysql_query("UPDATE test SET date = '$date'  WHERE id = '$test_id'");
                    break;
                    default:
                        // DO NO THING.
                }
            }
        }
    }
    // Whenever this wiil be fetched it will be updated.
    $query = "SELECT * FROM test ORDER BY `id` ASC LIMIT 3";
    $result = mysql_query($query);
    echo "<h2>Seria A</h2><hr/>
    <br/>Welcome, ".$username."! <a href='php/logout.php'><b>LogOut</b></a><br/>";
    while($row = mysql_fetch_array($result)){
        $id = $row['id'];
        $home = $row['home'];
        $away = $row['away'];
        $win = $row['win'];
        $draw = $row['draw'];
        $lose = $row['lose'];
        echo "<br/>",$id,") " ,$home, " - ", $away;
        echo "
        <form action='seria.php' method='post'>
        <select name='test[$id]'>        
            <option value=\"\">Parashiko</option>
            <option value='1'>1</option>
            <option value='X'>X</option>
            <option value='2'>2</option>
       </select>
       <input type='submit' name='submit' value='Submit'/>
        <br/>
        </form><br/>";        
        echo "Totali ", $sum = $win+$lose+$draw, "<br/><hr/>"; 
    } 
    }else{
        $error = "<div id='hello'>Duhet te besh Log In qe te vendosesh parashikime ndeshjesh<br/><a href='php/login.php'>Kycu Ketu</a></div>";
    }
 ?>
 
     
     
     
    