Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6年前关闭。
                                                                                            
                
        
问题在于$ prenume回显有效,而$ comentarii不起作用。我尝试了带引号和不带引号。如果我在while循环中回显$ comentarii,它将回显。我只有1行文字可以从数据库检索。请帮忙!谢谢 !

$gaseste_elevul = "SELECT prenume_elev, comentarii
FROM elevi
WHERE kod_utilizator=1";
    $gaseste_elevul_query = mysql_query($gaseste_elevul);

    while($elevul = mysql_fetch_array($gaseste_elevul_query))
    {
        $prenume = $elevul['prenume_elev'];
        $comentarii = $elevul['comentarii'];


    }
    if($comentarii = NULL)
    {
        echo "Momentan nu aveti informari pentru $prenume!";
    }

    else
      {
    echo "Mai jos aveti informarile pentru $prenume:";
    echo "$comentarii";

  }//sfarsit else


我还尝试在while循环中执行整个if($ comentarii = NULL),但没有结果。

最佳答案

更改

if($comentarii = NULL)




if($comentarii == NULL)


您的第一个语句将$comentarii设置为null,这就是为什么它不回显任何内容的原因。

10-05 23:09