<marquee behavior="alternate" scrolldelay="1" scrollamount="2">
<?php do { ?>
<?php echo $row_Recordset1['Name']; ?>:
<?php echo $row_Recordset1['Text']; ?>
•
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</marquee>
<?php mysql_free_result($Recordset1); ?>
2 に答える
1
次の代わりに、ユーザーにわかりやすいメッセージを出力しますNULL
。
<?php echo (NULL === $row_Recordset1['Text']) ? "No value" : $row_Recordset1['Text']; ?>
xil3 が示すように、次のパターンも使用できます (ドキュメントから)。
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
于 2010-07-06T21:32:26.783 に答える
1
今書いた方法では、$row_Recordset1 は最初にループに入ったときに null になります。
私はあなたのためにそれを書き直しました:
<marquee behavior="alternate" scrolldelay="1" scrollamount="2">
<?php while($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?>
<?php echo (($row_Recordset1['Name'] != null) ? $row_Recordset1['Name'] : 'n/a'); ?>:
<?php echo (($row_Recordset1['Text'] != null) ? $row_Recordset1['Text'] : 'n/a'); ?>
•
<?php } ?>
</marquee>
<?php mysql_free_result($Recordset1); ?>
于 2010-07-06T21:33:46.853 に答える