0
可以請別人幫我嗎?我在學校做的工作,我不知道如何連接這兩個表。MySQL連接表
我有兩個表:
|Analyze | | Data
+-------------------------+ +-------------------------+
| id_analyze | Name | | id_analyze | Standard |
--------------------------- -------------------------
| 1 | One | 1 | A.11 |
| 2 | two | 1 | A.12 |
| 3 | tree | 1 | A.13 |
| 4 | four | 2 | A.21 |
| 5 | five | 2 | A.22 |
| id_analyze | Name | 3 | A.31 |
一切,我需要的是得到網頁上輸出這兩個表所示:
| One | A.11 |
| | A.12 |
| | A.13 |
---------------
| Two | A.21 |
| | A.22 |
我嘗試了很多上市,但沒有工作。例如:
$choose = mysql_query("select * FROM Analyze", $connection);
$choose2 = mysql_query("select * FROM Data,Analyze WHERE Data.id_analyze = Analyze.id_analyze", $connection);
while ($row = mysql_fetch_array($choose)){
while ($row2 = mysql_fetch_array($choose2)) {
$Name = $row['Name'];
$Standard = $row2['Standard'];
}
}
結果環路瞭解'JOIN's –
請[停止使用'mysql_ *'功能(http://stackoverflow.com/questions/12859942/why-不應該-I-使用MySQL的函數式的PHP)。 [這些擴展](http://php.net/manual/en/migration70.removed-exts-sapis.php)已在PHP 7中刪除。瞭解[編寫](http://en.wikipedia.org/ wiki/Prepared_statement)語句[PDO](http://php.net/manual/en/pdo.prepared-statements.php)和[MySQLi](http://php.net/manual/en/mysqli.quickstart .prepared-statements.php)並考慮使用PDO,[這真的很簡單](http://jayblanchard.net/demystifying_php_pdo.html)。 –