<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); ?>
views:
52answers:
2
+1
A:
Print a friendly message to the user instead of NULL
:
<?php echo (NULL === $row_Recordset1['Text']) ? "No value" : $row_Recordset1['Text']; ?>
As xil3 illustrates, you can also use this pattern (from the docs):
// 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"];
}
Dolph
2010-07-06 21:32:26
`($row_Recordset1['Text']!='NULL')` This is wrong! This is correct: `($row_Recordset1['Text']!==NULL)` See: http://php.net/manual/en/language.operators.comparison.php
Dolph
2010-07-06 21:40:38
+1
A:
The way you have it written right now, $row_Recordset1 will be null the first time it goes into the loop.
I've rewritten it for you:
<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); ?>
xil3
2010-07-06 21:33:46