简体   繁体   中英

php join query for multiple tables

Can anyone tell me how i can get the value for project_title, project_id, level_of_want, and selection_id. When i submit this i get No database selected error.

$query_Name = "SELECT u.Student_Surname, u.Student_Forename, p2.Project_Title,     
p2.Project_id, s.level_of_want, s.selection_id
FROM users u
INNER JOIN projects p2 ON u.id = p2.Project_Lecturer
INNER JOIN selection s ON p2.Project_id = s.id_project
INNER JOIN users u2 ON s.student_id = u2.id
WHERE u2.Username = ".$_SESSION['MM_Username']." ORDER BY selection_id ASC" ;
$Name = mysql_query($query_Name, $projectsite) or die(mysql_error());
$row_Name = mysql_fetch_assoc($Name);
$totalRows_Name = mysql_num_rows($Name);

在连接到mysql服务器库之后,您应该使用mysql_select_db函数显式选择数据库

mysql_select_db($bd);

我们需要看看你是如何联系的

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM