web前段 php 连接 mysql 两个表查询,结果分别显示在同一个页面上

如我有表一:table1(snum,sname,idcard);表二:table2(snum,sname,class);
现在我需要用php连接这两个表,然后在页面上有个搜索框,输入一个sunm,然后在同一个页面显示两张表对应的结果。

1:定一张表为主表,左连接
2:分别查出来,加到一个数组中

 select a.*,b.*  from table1 as a inner join table2 as b on a.snum=b.snum;

如果这两个表关联的话,可以用关联查询,如果不是关联表,就可以用很粗暴的方法,将两个查询的结果拼起来,然后显示在页面上

select a.sum ,a.sname , a. idcard ,b.class from table1 a ,table b where a.sum = b.sum;