<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); ?>
0
A
Répondre
1
Imprimer un message amical à l'utilisateur au lieu de NULL
:
<?php echo (NULL === $row_Recordset1['Text']) ? "No value" : $row_Recordset1['Text']; ?>
Comme xil3 illustre, vous pouvez également utiliser ce modèle (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"];
}
+0
'($ row_Recordset1 ['Text']! = 'NULL')' C'est faux! Ceci est correct: '($ row_Recordset1 ['Text']! == NULL)' Voir: http://php.net/manual/fr/language.operators.comparison.php – Dolph
1
La façon dont vous l'avez écrit Pour le moment, $ row_Recordset1 sera nul la première fois qu'il ira dans la boucle.
je l'ai réécrite pour vous:
<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); ?>
Pas une vraie question? Comment? La gestion correcte des valeurs NULL semble très réelle ... – EFraim
L'élément [
@EFraim Je crois qu'ils se réfèrent au $ row_Recordset1 ['Text'] auquel cas, s'il est NULL, il pourrait finir par imprimer juste un nom et aucun texte suivant. La question est sur ce qu'il faut faire alors je suppose ... –