获取数据

cxg65641074 2009-09-30 02:59:42
我已在一张表中将其中的数据获取出来,作为列名,再从另一张表中获取数据与已经取得的列名相对应,我该怎么做?我用的是php+mysql.代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>行业数据库 表字段管理</title>
<script type="text/javascript">
function quit()
{
window.location="management_tablename.php"
}
</script>
</head>
<body>
<?php
//连接数据库服务器
$con = mysql_connect("localhost","root","123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
//选择数据库
$db_selected = mysql_select_db("industry",$con);
//执行字符集
mysql_query("set names GBK");
if($_GET)
{
$table_chinesename=$_GET['table_chinesename'];
//选择数据表
$result = mysql_query("SELECT * FROM tablestruct WHERE `table_chinesename` = '$table_chinesename'");

//输出表单
echo "<table width='713' height='88' border='1'>
<tr>
<td height='41' colspan='100%'>账户管理>表管理>表名管理>表数据管理</td>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<td>" . $row['field_chinesename'] . "</td>";
}
echo "</table>";
}
?>
</body>
</html>
...全文
35 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zijian85 2009-09-30
  • 打赏
  • 举报
回复
楼主,sql语句用左外联查询就行哈,至于如何写这句话,baidu吧,这样对你有好处哈

21,881

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧