Below I have a table that displays the data from MySQL, in the database, there's three column for storing different languages of msg (ie traditionalmessage, simplifiedmessage &engmessage).
Each individual can pick their preferred language, in the view page
, there's an msg column
, it will show people's msg with their preferred languages
Like this
People Language Msg
A 繁體 物理治療
B Eng Physiotherapy
<table>
<?php
$result = mysql_query("SELECT *
FROM treatmentdetail WHERE
language ='繁體' OR language ='ENG' OR language ='简体'");?>
<?php
$specific = [];
while($row = mysql_fetch_array( $result ,MYSQL_ASSOC)) {?>
<tr>
<td><input class="form-control" type="text" size="1" name="people[]"
value="<?php echo $row['people'] ?>"></td>
<td><input class="form-control" type="text" size="1" name="language[]"
value="<?php echo $row['language'] ?>"></td>
<td width="200px"><input class="form-control" type="text" size="1"
name="msg[]" value="
<?php if($row['language'] == '繁體')
{
echo $row['traditionalmessage'];}
else if($row['language'] == 'ENG')
{
echo $row['engmessage'];}
if($row['language'] == '简体')
{
echo $row['simplifiedmessage'];} ?>">
</td>
Close the table
<?php
echo "</tr>";
echo "</table>";echo "</form>";?>
Now I'd like to get all the values of the msg column
and put them in an array called $specific
<?php $specific = [
"message" => $row["engmessage"]
];?>
Here I just hard coded to get the values of all message. But as there are gonna be traditionalmessage & simplifiedmessage as well. So it has to be dynamic.
So how can I get the all the values of the msg column (which may have values retrieved from multiple database columns
i.e. traditionalmessage/
simplifiedmessage /engmessage)
and put those values into an array
Hope u understand what I meant.
Many thanks.