php - MySQL List all entries and sort by ID -
somehow can't list mysql entries id. result error if try sort 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`  my code:
<?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 * adressbuch order 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\"> </td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"partnumbers\">part numbers:</td>"; echo "<td class=\"first\">$partnumber</td>"; echo "<td class=\"second\"> </td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"productcode\">product code:</td>"; echo "<td class=\"first\">$productcode</td>"; echo "<td class=\"second\"> </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>"; ?>  if set select * adressbuch last entry.
fixed:
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\"> </td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"partnumbers\">part numbers:</td>"; echo "<td class=\"first\">$partnumber</td>"; echo "<td class=\"second\"> </td>"; echo "</tr>"; echo "<tr>"; echo "<td class=\"productcode\">product code:</td>"; echo "<td class=\"first\">$productcode</td>"; echo "<td class=\"second\"> </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 ); ?>  
Comments
Post a Comment