【发布时间】:2015-03-11 13:45:56
【问题描述】:
我正在尝试在 php 中的 textarea 内的数据库表中的两列中显示数据,在标题标签号和 scc 下
它应该是这样的。
但是它在一行中读取所有内容,没有中断,看起来很乱:
这是我的代码,我希望能得到一些关于如何以表格格式或其他简洁方式组织它的建议。 bold 中的行是我在 textarea 中显示了两列数据。 $MyText1 & $Out1 在 textarea 中显示数据。
// mysqli_fetch_assoc
$myquery = "SELECT `scc`, `tag_number` FROM `milk`
";
$result = mysql_query($myquery);
$MyText = "";
$MyText1 = "";
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_array($result))
{
$Scc = $row['scc'];
$TagNumber= $row['tag_number'];
//$MyText.= $row['tag_number'];
$MyText .= $TagNumber . ', ';
***$MyText1 .= $TagNumber . $Scc . ',';***
***$msg1 = "TagNumber : Scc : " .$row[0].$row[1];***
// $out1 = '<p align="left"><textarea rows="5" cols="25" disabled = "true">' .$msg1. '</textarea></p>';
//mysqli_fetch_array($result)
// echo $out1;
if($row['scc'] > 50 ) {
$msg = ("'Somanic cell count levels are meeting the expected output levels in the herd.' $MyText. 'are above the average' 'No further action should be taken according to current production levels '");
//$msg = $TagNumber;
//echo $row.$TagNumber;
}
elseif ($Scc < $average) {
$msg = 'SCC levels are below the average.';
}else{
$msg = 'some other message';
}
}
***$out1 = '<p align="left"><textarea rows="5" cols="25" disabled = "true">'.$msg1.$MyText1. '</textarea></p>';***
//mysqli_fetch_array($result)
***echo $out1;***
【问题讨论】:
-
不要用锤子灌浆瓷砖。为什么要使用文本区域来存储表格数据?