I'm trying to echo data from a database in the format shown below;
|column-1|column-2|column-3|column-4|column-5|
|--------|--------|--------|--------|--------|
|My Name | Date |Message | People |Phone #s|
| People |Phone #s|
| People |Phone #s|
| People |Phone #s|
| People |Phone #s|
That means, the data I'm selecting from the database is such that the people in column 4, 5 received the message (column-3) from the person on column-1. But according to my code that echoes data from the db, I have a new column for every other person on column 4 and 5 as shown below;
|column-1|column-2|column-3|column-4|column-5|
|--------|--------|--------|--------|--------|
|My Name | Date |Message | People |Phone #s|
|My Name | Date |Message | People |Phone #s|
|My Name | Date |Message | People |Phone #s|
|My Name | Date |Message | People |Phone #s|
|My Name | Date |Message | People |Phone #s|
Below is my php code that generates the table;
echo "<table id='table'>";
while($row=pg_fetch_assoc($result)){echo "<tr>";
echo "<td align='left' width='200'>" . $row['message_by'] . "</td>";
echo "<td align='left' width='200'>" . $row['message_date'] . "</td>";
echo "<td align='left' width='200'>" . $row['message_text'] . "</td>";
echo "<td align='left' width='200'>" . $row['phone_number'] . "</td>";
echo "<td align='left' width='200'>" . $row['recipient_name'] . "</td>";
echo "</tr>";}
echo "</table>";
So the question is how can I output column 4 and 5 data into a single cell or alternatively, echo out the data into different cells without repeating columns 1 to 3?
rowspanandcolspanattroftd.rowspanandcolspanwill require me to assign them a number, how can I achieve that dynamically according to the number of people returned from the db?