0

嘿,伙计们,我正在尝试连接到数据库并从表中收集一些数据,zuordnung但它无法正常工作,我得到的一切都是白页,我很沮丧,因为我找不到错误,也许另一双眼睛会看到它所以在这里是我到目前为止:

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php
    include ("db_login.php");

    $link = mysql_connect($host, $user, $pass) or die ("Keine Verbindung zu der Datenbank moeglich.");
    mysql_select_db($db, $link);

    $sql = "SELECT ID_Zuordnung, HW_Typ, Hostname_alt, Username, Emailadresse, Datum_Ausgabe, Abteilung 
        FROM zuordnung
        WHERE Status_Tausch='OK' AND Status_Altgeraet='NOK'
        ORDER BY Hostname_alt;";

    $result = mysql_query($sql);
    $resultarray = mysql_fetch_array($result); 
            echo('<p>'.$resultarray['HW_Typ']."</p>");
            echo('<p>'.$resultarray['Hostname_alt']."</p>");
            echo('<p>'.$resultarray['Username']."</p>");
            echo('<p>'.$resultarray['Emailadresse']."</p>");
            echo('<p>'.$resultarray['Datum_Ausgabe']."</p>");
            echo('<p>'.$resultarray['Abteilung']."</p>");
    ?> 
 </body>
</html>
4

3 回答 3

1
while($resultarray = mysql_fetch_array($result))
{
            echo('<p>'.$resultarray['HW_Typ']."</p>");
            echo('<p>'.$resultarray['Hostname_alt']."</p>");
            echo('<p>'.$resultarray['Username']."</p>");
            echo('<p>'.$resultarray['Emailadresse']."</p>");
            echo('<p>'.$resultarray['Datum_Ausgabe']."</p>");
            echo('<p>'.$resultarray['Abteilung']."</p>");

}
于 2012-10-08T13:01:32.113 回答
0

试试这个

require_once($_SERVER['DOCUMENT_ROOT']."db_login.php");

而不是包括

resultarray如果您有超过 1 条记录,您需要在 while 循环中回显。

于 2012-10-08T13:03:30.090 回答
0

你忘了循环
使用循环吗,像这样。

while($resultarray = mysql_fetch_array($result))
{
echo('<p>'.$resultarray['HW_Typ']."</p>");
            echo('<p>'.$resultarray['Hostname_alt']."</p>");
            echo('<p>'.$resultarray['Username']."</p>");
            echo('<p>'.$resultarray['Emailadresse']."</p>");
            echo('<p>'.$resultarray['Datum_Ausgabe']."</p>");
            echo('<p>'.$resultarray['Abteilung']."</p>");

}
于 2012-10-08T13:05:13.363 回答