![](/img/trans.png)
[英]How to get the information from table to another page using PHP and MYSQL?
[英]How to get information from 2 tables at once in PHP and MySQL?
<?php
include('includes/config.php');
$topi = $_GET['id']; //id of url
mysql_select_db("ban", $con);
$query = "SELECT * FROM `basic` WHERE id = '$topi' LIMIT 0, 30";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
$aa = $row['item'];
$cc = $row['moreinfo'];
$dd = $row['contactinfo'];
$ff = $row['id'];
在這個腳本中,我從表basic
中獲取信息,但我想從另一個名為users
的表中檢索數據。 如何一次從兩個表中檢索數據?
users
表由以下列組成:
您將在另一個表上使用 JOIN。
$query = "SELECT *
FROM basic b
JOIN users u ON b.user_id = u.user_id
WHERE id = '$topi'
LIMIT 0, 30";
類似的東西,但基於你的領域。
請注意:ON 子句指定您要查找的匹配項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.