从PHP / MySQL中的2个表获取信息的问题 [英] problem with getting info from 2 tables in PHP / MySQL

查看:58
本文介绍了从PHP / MySQL中的2个表获取信息的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张桌子。一,我手动插入数据进行HTTP

身份验证。它有3个字段:用户名,密码,学校。一旦

用户输入了正确的u和p,学校名称就会显示硬编码的

到一个提交到另一个表中的表单中。所以,两个表中总共有一个

''school''字段。现在,我想从第二张表中抽取所有

的信息打印出来但是遇到了问题。所以

远,我有类似的东西:


$ sql = mysql_query(" SELECT * FROM logintable,datatable WHERE

logintable.school = datatable.school");

while($ row = mysql_fetch_array($ sql)){


print(" $ row [school],$ row [field1]等....


}

解决方案

sql = mysql_query(" SELECT * FROM logintable,datatable WHERE

logintable.school = datatable.school");

while(


< blockquote> row = mysql_fetch_array(


sql)){


print("


I''ve got 2 tables. One, I manually insert data into for HTTP
authentication. It has 3 fields: username, password, school. Once the
user enters the corrrect u and p, the school name shows up hard coded
into a form that gets submitted into another table. So, there is a
''school'' field in both tables that always match. Now, I want to draw all
the info from this second table to print out but am having problems. So
far, I''ve got something like:

$sql = mysql_query("SELECT * FROM logintable, datatable WHERE
logintable.school = datatable.school");
while($row = mysql_fetch_array($sql)){

print("$row[school], $row[field1], etc....

}

解决方案

sql = mysql_query("SELECT * FROM logintable, datatable WHERE
logintable.school = datatable.school");
while(


row = mysql_fetch_array(


sql)){

print("


这篇关于从PHP / MySQL中的2个表获取信息的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆