表中只放了一行,其余的都没有! [英] Only 1 row is put into a table, the rest arent!

查看:80
本文介绍了表中只放了一行,其余的都没有!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在下面有这个代码并且它工作正常,除了事实上只有第一行放入表行而其余部分行不是。我错过了一些明显的东西吗我一直试图解决这个问题,我只是看不到错误/问题!



求助?



Hi,

I have this code below and it works fine, other than the fact that only the first row is put into a table row and the rest of the rows are not. Am I missing something obvious? I've been trying to fix this for a while and I just cant see the error/problem!

Help please?

		$messageFrom = $_REQUEST['messageFrom'];
		$messageTo = $_REQUEST['messageTo'];
        $db = Database::getConnection();
		$query = "SELECT * FROM messages WHERE messageTo = :to AND messageFrom = :from OR messageFrom = :to AND messageTo = :from ORDER BY messageDate DESC LIMIT 5";
		$output = $db->query($query);
		$output->bindParam(':to', $messageTo);
		$output->bindParam(':from', $messageFrom);
		$output->execute();
		$results = $output->fetchAll(PDO::FETCH_ASSOC);
		if (count($results) > 0){
			echo "<table>\n";
			echo "<tr><th colspan=2>Conversation</th></tr>\n";
foreach($results as $result){
				$from = $result['messageFrom'];
				$to = $result['messageTo'];
				$message = $result['message'];
				$messageID = $result['messageID'];
				echo "<tr>\n";
					if ($from == $messageFrom){
					echo "<td><div><p>$messageFrom</p>$message</div></td>";
					echo "</tr>\n";
					} else {
					echo "<td><div><p>$messageTo</p>$message</div></td>";
					echo "</tr>\n";
					}
				echo "</table>";
			}

推荐答案

messageFrom =
messageFrom =


_REQUEST [' messageFrom'];
_REQUEST['messageFrom'];


messageTo =
messageTo =


这篇关于表中只放了一行,其余的都没有!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆