How to take only one value from a cell with only 6 values?

I need to take the value of each hundred in a separate cell in the table below.

Thank you in advance. :)

$table .= "<tr>"; $table .= "<td>Skill:</td>"; $table .= "<td>".$row['pSkills']."</td>"; $table .= "</tr>"; 

Mysql column

    1 answer 1

    Based on the image you present (the data in the column) you will always have six elements (if more, you need an additional condition for the output). We pull them out of the database (I think you did it), then run the explode function, and then output the desired item or run it in a loop.

    Decision:

     $str = '0,1,2,3,4,5'; $mas = explode(',',$str); $table .= "<tr>"; $table .= "<td>Skill:</td>"; $table .= "<td>".$mas[0]."</td>"; $table .= "</tr>"; 

    Or cycle:

     foreach ($mas as $value) { $table .= "<tr>"; $table .= "<td>Skill:</td>"; $table .= "<td>".$value."</td>"; $table .= "</tr>"; } 

    PS Instead of $str insert $row['pSkills'] .

    • I only managed to pull out entirely through $ table. = "<Td>". $ Row ['pSkills']. "</ Td>"; Do not tell me how to get it out? - breddy 6:39 pm
    • @breddy my answer is the solution to your question? - doox911
    • Almost, I managed to pull out only all 6 elements, but I did not understand how to pull out only one - breddy
    • @breddy corrected the answer) - doox911
    • ,Thank you very much. - breddy pm