-3
Was ist falsch an diesem Code?Wie kann ich etwas aus einer anderen Datenbank bekommen?
echo "<table>";
echo "<tr><td>Machine Nummer</td><td>Eigenaar</td><td>Status</td><td>Locatie</td></tr>";
while($row = mysql_fetch_array($result)){
echo "<tr><td>" . $row['machineid'] . "</td><td> ". $eigenaar=mysql_query("SELECT userName FROM users WHERE userId =" . $row['eigenaar'] ."") ."</td><td>" . $row['status'] . "</td><td>" . $row['locatie'] . "</td></tr>";
}
echo "</table>";
$res=mysql_query("SELECT * FROM users WHERE userId=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
$query = "SELECT * FROM machines WHERE locatie='".$_SESSION['location']."'"; //You don't need a ; like you do in SQL
$result = mysql_query($query);
Ich möchte den eigenaar Namen Ausgang, der mit dem userId gleich aber ich bekomme nur die Ausgabe: Resource id # 9 Resource id # 10 Resource id # 11.
weil Sie den Wagen vor das Pferd stellen, * sozusagen * und Sie können keine Frage in ein Echo setzen. –
* "Was ist falsch an diesem Code?" * A: alles. Es ist nur völliger Unsinn; und Cargo-Kult-Programmierung, wie Marc sagen würde. –
*** Bitte [stoppen Sie mit mysql_ * 'Funktionen] (http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). *** [Diese Erweiterungen ] (http://php.net/manual/de/migration70.removed-exts-sapis.php) wurden in PHP 7 entfernt. Erfahren Sie mehr über [prepared] (http://en.wikipedia.org/wiki/Prepared_statement) Anweisungen für [PDO] (http://php.net/manual/en/pdo.prepared-statements.php) und [MySQLi] (http://php.net/manual/en/mysqli.quickstart.prepared- Statements.php) und erwäge die Verwendung von PDO, [es ist wirklich ziemlich einfach] (http://jayblanchard.net/demystifying_php_pdo.html). –