私は文テーブルを持っています:
======================================================================
| id_row | id_document | id_sentence | sentence |
======================================================================
| 1 | 1 | 0 | Example sentences A |
| 2 | 1 | 1 | Example sentences B |
| 3 | 2 | 0 | Example sentences C |
| 4 | 2 | 1 | Example sentences D |
======================================================================
=> のように同じ id_document を持つ文を配列にマージしたいArray( [1] => Array ( [0] => Example sentences A [1] => Example sentences B ) [2] => Array ( [0] => Example sentences C [1] => Example sentences D ))
コードは次のとおりです。
<?php
require_once 'conf.php';
$sql = mysql_query('SELECT sentence FROM sentence group by id_document') or die(mysql_error());
while ($row = mysql_fetch_array($sql)) {
$sentence[] = $row['sentence'];
}
print_r($sentence);
?>
しかし、id_document ごとに 1 つの文しか得られません。助けて。ありがとうございました :)