Home > Backend Development > PHP Tutorial > 如何查另一个表字段中的数据

如何查另一个表字段中的数据

WBOY
Release: 2016-06-13 12:46:02
Original
786 people have browsed it

怎么查另一个表字段中的数据
现在我有一个tb_activity表和一个tb_participate表
表tb_participate中的p_activity字段与表tb_activity中的a_num值相同
通过

<br />
<?php<br />
$sql8="select * from tb_participate where p_voluteer = '$fnum'";<br />
$result8=mysql_query($sql8)or die ('数据库查询失败!');<br />
while($row=mysql_fetch_array($result8)){<br />
	 echo $row['p_activity'].'<br/>';<br />
}<br />
?>
Copy after login

我可以输出表tb_participate中p_activity字段的所有值(也就是表tb_activity中a_num的值)
但我想同时输出表tb_activity中a_name字段的值
请问应该怎么改写代码?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template