简体   繁体   English

从Mysql服务器中选择两个表

[英]Select two tables from Mysql server

I'm trying to make an evaluation stars system and I have two tables: user and evaluation. 我正在尝试制作一个评估星级系统,我有两个表:用户和评估。 Now I would like to show my vote for every user? 现在,我想对每个用户表示投票? Every answer is welcome. 欢迎每个答案。 Thanks in advance! 提前致谢!

Are you looking for what SQL query you want to use to show the evaluation rate for every user? 您是否正在寻找要用于显示每个用户评估率的SQL查询? If yes, this will help you: 如果是,这将帮助您:

SELECT user.name AS username, evaluation.value AS evaluation_value
FROM user  
INNER JOIN evaluation ON user.id = evaluation.user_eval

I think that user_val in the evaluation table is the user id. 我认为评估表中的user_val是用户ID。 If yes you can use the above query. 如果是,则可以使用上面的查询。 If not modify the query to target the column where you save the user ID. 如果没有,请修改查询以将用户ID保存到的列为目标。

make a file "list_all_values.php" this is code - 制作文件“ list_all_values.php”,这是代码-

<?php
$sql="SELECT * FROM evaluation";
$result = $conn->query($sql);
// $conn is your connection to database
echo '
<html>
<table>
<tr>
<th>user_eval</th>
<th>value</th>
</tr>';
while($row = $result->fetch_assoc()){
echo '<tr><td>'.$row['user_eval'].'</td><td>'.$row['value'].'</td></tr>';
}
echo '</table>
</html>';
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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