我设法从回复表中获得回复的唯一方法是通过组 concat,但所有回复都出现在一行中。我需要每行显示每个回复。在 mysql 查询之后,我尝试以各种方式对其进行爆炸。我发现的大多数爆炸代码仅适用于 echo 而不适用于一行。他们是一种爆炸方式还是另一种分离回复的方式。基本上,一旦我对帖子/图像的回复进行分组,只会出现一个回复,但是当我将所有回复分组连接时,只会出现一行。我已经设法用空格或逗号分隔它们,但它们仍然保持在一行中。
<?php
$sql = "
SELECT images.mid, images.id, images.who, header.username, images.message, images.name, GROUP_CONCAT(reply.reply
SEPARATOR 0x1E ) as heat
FROM header, images
LEFT JOIN reply ON reply.reply = reply.mid
OR reply.mid = images.mid
WHERE images.name IS NOT NULL = header.id
AND images.who IS NOT NULL
AND images.message IS NOT NULL
GROUP BY images.mid
";
$rs = mysql_query( $sql );
while ( $row = mysql_fetch_array( $rs )
) {
$name = $row['name'];
$mid = $row['mid'];
$title = $row['title'];
$who = $row['who'];
$details = $row['details'];
$message = $row['message'];
$id = $row['id'];
$heat = explode(',', $row['heat']);
$heat = array (".",$row['heat']);
foreach($heat as $heat)
$row=mysql_fetch_array($rs);
if($row){
$name= $row['name'];
?>
<td>
<table>
<tr>
<td>
<a href="a/<?=$name ?>" rel='lightbox' title='$timestamp - $message'> <img src= "a/<?=$name ?>" width='150' height='100'" > </a> </td>
</tr>
<tr> <td> <?=$row['name'] ?>
</td> </tr>
<tr>
<td> <?=$row['who'] ?> </td> </tr>
<tr>
<td> <?=$row['message'] ?></td> </tr>
<tr>
<td> <?=$row['id'] ?></td> </tr>
<tr>
<td> <?=$row['mid'] ?> </td> </tr>
<tr>
<td> <?=$row['username'] ?></td>
</tr><tr>
<td> <?=$row['heat'] ?></td>
</tr>
</table>
</td>
<?
}
else{
echo "<td> </td>"; //If there are no more records at the end, add a blank column
}
} while($row);
echo "</table>";
?>
</div>
</body>
</html>
这是我通过组 concat 得到的回复的结果。
She fell, she ate, she came, its good, okay.
我也设法把它变成了一个数组,但我也被困住了。对于那些了解 CSS 的人。他们是一种将数据数组放入行的方法。我记得看到它,但不记得怎么做。