0

どういうわけか、すべてのMySQLエントリをIDで一覧表示できません。IDで並べ替えようとすると、結果はエラーになります。

Notice: Undefined variable: url_bild in /Users/fatih/Sites/phpform/neu/adressen-anzeigen.php on line 66`
Notice: Undefined variable: title in /Users/fatih/Sites/phpform/neu/adressen-anzeigen.php on line 68`

私のコード:

<?php
require_once ('konfiguration.php');

// Nutzen von Datenbank (Name ist hinterlegt in Konstante MYSQL_DATENBANK
$db_sel = mysql_select_db( MYSQL_DATENBANK )
    or die("Auswahl der Datenbank fehlgeschlagen");

$sql = " SELECT * FROM adressbuch order by id asc";
$db_erg = mysql_query( $sql );
if ( ! $db_erg )
{
    die('Ungültige Abfrage: ' . mysql_error());
}


while ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
{
    $title          = $zeile['title'];
    $description    = $zeile['description'];
    $applepart      = $zeile['applepart'];
    $partnumber     = $zeile['partnumber'];
    $productcode    = $zeile['productcode'];
    $compatibility  = $zeile['compatibility'];
    $url_bild       = $zeile['url_bild'];
    $price          = $zeile['price'];
}
mysql_free_result( $db_erg );


echo "<table id=\"products\" border=\"0\">";
echo    "<tr>"; if ( $url_bild <> "" ) {
echo        "<td class=\"thumbnail\"><img src=\"$url_bild\" /></td>"; }
echo        "<td class=\"description\"><h1>$title</h1>";
echo        "<p>$description</p>";
echo            "<table border=\"0\">";
echo                "<tr>";
echo                    "<td class=\"applepart\">Apple Part#:</td>";
echo                    "<td class=\"first\">$applepart</td>";
echo                    "<td class=\"second\">&nbsp;</td>";
echo                "</tr>";
echo                "<tr>";
echo                    "<td class=\"partnumbers\">Part Numbers:</td>";
echo                    "<td class=\"first\">$partnumber</td>";
echo                    "<td class=\"second\">&nbsp;</td>";
echo                "</tr>";
echo                "<tr>";
echo                    "<td class=\"productcode\">Product Code:</td>";
echo                    "<td class=\"first\">$productcode</td>";
echo                    "<td class=\"second\">&nbsp;</td>";
echo                "</tr>";
echo                "<tr>";
echo                    "<td class=\"compatibility\">Compatibility:</td>";
echo                    "<td class=\"first\">$compatibility</td>";
echo                    "<td class=\"second\"></td>";
echo                "</tr>";
echo        "</table>";
echo        "</td>";
echo        "<td class=\"price\"><h1>$price</h1></td>";
echo    "</tr>";
echo "</table>";

?>

SELECT * FROM adressbuch最後のエントリだけを取得するように設定した場合。

4

1 に答える 1

0

修理済み:

echo "<table id=\"products\" border=\"0\">";    
while ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
{
    $title          = $zeile['title'];
    $description    = $zeile['description'];
    $applepart      = $zeile['applepart'];
    $partnumber     = $zeile['partnumber'];
    $productcode    = $zeile['productcode'];
    $compatibility  = $zeile['compatibility'];
    $url_bild       = $zeile['url_bild'];
    $price          = $zeile['price'];

echo    "<tr>"; if ( $url_bild <> "" ) {
echo        "<td class=\"thumbnail\"><img src=\"$url_bild\" /></td>"; }
echo        "<td class=\"description\"><h1>$title</h1>";
echo        "<p>$description</p>";
echo            "<table border=\"0\">";
echo                "<tr>";
echo                    "<td class=\"applepart\">Apple Part#:</td>";
echo                    "<td class=\"first\">$applepart</td>";
echo                    "<td class=\"second\">&nbsp;</td>";
echo                "</tr>";
echo                "<tr>";
echo                    "<td class=\"partnumbers\">Part Numbers:</td>";
echo                    "<td class=\"first\">$partnumber</td>";
echo                    "<td class=\"second\">&nbsp;</td>";
echo                "</tr>";
echo                "<tr>";
echo                    "<td class=\"productcode\">Product Code:</td>";
echo                    "<td class=\"first\">$productcode</td>";
echo                    "<td class=\"second\">&nbsp;</td>";
echo                "</tr>";
echo                "<tr>";
echo                    "<td class=\"compatibility\">Compatibility:</td>";
echo                    "<td class=\"first\">$compatibility</td>";
echo                    "<td class=\"second\"></td>";
echo                "</tr>";
echo        "</table>";
echo        "</td>";
echo        "<td class=\"price\"><h1>$price</h1></td>";
echo    "</tr>";
}
echo "</table>";
mysql_free_result( $db_erg );    

?>
于 2012-07-07T13:30:19.780 に答える