php查询数据库表问题

php中文网
发布: 2016-06-23 14:09:52
原创
1268人浏览过

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>学生课题查询</title><style type="text/css"><!--.STYLE1 {font-size: 14px}--></style></head><body><?php//######################学生查询所选课题########################## include "config.php"; include "header.php";?> <?if($search){  if ($xuehao=="")  {	echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>请填写您的学号!</big></b></font></p>";	echo "<meta http-equiv=\"refresh\" content=\"1;url=query.php\">";	exit;	 }    $query="select * from $student_table where xuehao='$xuehao'"; mysql_query("set names 'gb2312'"); $result=mysql_query($query); $row=mysql_fetch_array($result); if($row==0) {	echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>你还没有注册,或者你的输入有误,请重新输入!</big></b></font></p>";	echo "<meta http-equiv=\"refresh\" content=\"2;url=query.php\">";    exit; }  $query="select id as sm from $student_table where xuehao='$xuehao'"; mysql_query("set names 'gb2312'"); $result=mysql_query($query); $row=mysql_fetch_array($result); if($row[sm]==0) {	echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>你还没有选择课题,请去选题!</big></b></font></p>";	echo "<meta http-equiv=\"refresh\" content=\"2;url=keti_list.php\">";    exit; } ?><table width="700" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">  <tr>   <td width="78" height="30" bgcolor="#FFFFFF">       <div align="center" class="text">         <p class="STYLE1">学生学号</p>      </div>    </td>    <td width=97 height="30" bgcolor="#FFFFFF">       <div align="center" class="STYLE1">学生姓名</div>    </td>    <td width="329" height="30" bgcolor="#FFFFFF">     <div align="center" class="STYLE1"> 课题名称 </div>    </td>    <td width=106 height="30" bgcolor="#FFFFFF">       <div align="center" class="STYLE1">指导教师</div>    </td>    <td width=84 height="30" bgcolor="#FFFFFF">     <div align="center" class="STYLE1">职称</div>    </td>  </tr>   <?   $n=0;    $query=mysql_query("select * from $jiaoshi_table,$student_table where $jiaoshi_table.id=$student_table.id and $student_table.xuehao='$xuehao'");   mysql_query("set names 'gb2312'");   while($row=mysql_fetch_array($query)){        if(($n%2)!='0'){ 	  echo "<tr bgcolor=#FFFFff>";}	  else{	  echo "<tr bgcolor=#E4E4E4>";	  }     echo"	 <td   height='22' class='STYLE1'> <div align='center'>".$row['xuehao']."</div></td>	 <td   height='22'> 		<div align='center' class='STYLE1'>".$row['name']."</div></td>    <td   height='22' class='STYLE1'> <div align='center'>".$row['subject']."</div></td>    <td   height='22' class='STYLE1'> <div align='center'>".$row['teacher']."</div></td>	<td   height='22' class='STYLE1'> <div align='center'>".$row['zhicheng']."</div></td>  </tr> ";   $n++;   } ?></table> <p> </p>
                    <div class="aritcle_card">
                        <a class="aritcle_card_img" href="/ai/1589">
                            <img src="https://img.php.cn/upload/ai_manual/000/000/000/175680266950579.png" alt="采风问卷">
                        </a>
                        <div class="aritcle_card_info">
                            <a href="/ai/1589">采风问卷</a>
                            <p>采风问卷是一款全新体验的调查问卷、表单、投票、评测的调研平台,新奇的交互形式,漂亮的作品,让客户眼前一亮,让创作者获得更多的回复。</p>
                            <div class="">
                                <img src="/static/images/card_xiazai.png" alt="采风问卷">
                                <span>20</span>
                            </div>
                        </div>
                        <a href="/ai/1589" class="aritcle_card_btn">
                            <span>查看详情</span>
                            <img src="/static/images/cardxiayige-3.png" alt="采风问卷">
                        </a>
                    </div>
                <?php include "foot.php";?>
登录后复制

当我输入学号查询的时候,运行结果却是一堆乱七八糟的东西。。。
注:我的表名叫做teacher,student


回复讨论(解决方案)

你截的图看看       

你截的图看看       

你截的图看看       
哇塞,版主亲自回复。偶表示好激动地说。

你没开启段标签
  改成

你没开启段标签
  改成

你没开启段标签
  改成

你代码到91行之前都在执行,你就不能开全了吗
      $n=0;    $query=mysql_query("select * from $jiaoshi
这里还有一个,你没改成

你代码到91行之前都在执行,你就不能开全了吗
      $n=0;    $query=mysql_query("select * from $jiaoshi
这里还有一个,你没改成

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>学生课题查询</title><style type="text/css"><!--.STYLE1 {font-size: 14px}--></style></head><body><?php//######################学生查询所选课题########################## include "config.php"; include "header.php";?><?phpif($search){  if ($xuehao=="")  {	echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>请填写您的学号!</big></b></font></p>";	echo "<meta http-equiv=\"refresh\" content=\"1;url=query.php\">";	exit;	 }    $query="select * from $student_table where xuehao='$xuehao'"; mysql_query("set names GB2312"); $result=mysql_query($query); $row=mysql_fetch_array($result); if($row==0) {	echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>你还没有注册,或者你的输入有误,请重新输入!</big></b></font></p>";	echo "<meta http-equiv=\"refresh\" content=\"2;url=query.php\">";    exit; }  $query="select id as sm from $student_table where xuehao='$xuehao'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query); $row=mysql_fetch_array($result); if($row[sm]==0) {	echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>你还没有选择课题,请去选题!</big></b></font></p>";	echo "<meta http-equiv=\"refresh\" content=\"2;url=keti_list.php\">";    exit; } ?><table width="700" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">  <tr>   <td width="78" height="30" bgcolor="#FFFFFF">       <div align="center" class="text">         <p class="STYLE1">学生学号</p>      </div>    </td>    <td width=97 height="30" bgcolor="#FFFFFF">       <div align="center" class="STYLE1">学生姓名</div>    </td>    <td width="329" height="30" bgcolor="#FFFFFF">     <div align="center" class="STYLE1"> 课题名称 </div>    </td>    <td width=106 height="30" bgcolor="#FFFFFF">       <div align="center" class="STYLE1">指导教师</div>    </td>    <td width=84 height="30" bgcolor="#FFFFFF">     <div align="center" class="STYLE1">职称</div>    </td>  </tr>   <?php   $n=0;    $query=mysql_query("select * from $jiaoshi_table,$student_table where $jiaoshi_table.id=$student_table.id and $student_table.xuehao='$xuehao'");   mysql_query("set names GB2312");   while($row=mysql_fetch_array($query)){        if(($n%2)!='0'){ 	  echo "<tr bgcolor=#FFFFff>";}	  else{	  echo "<tr bgcolor=#E4E4E4>";	  }     echo"	 <td   height='22' class='STYLE1'> <div align='center'>".$row['xuehao']."</div></td>	 <td   height='22'> 		<div align='center' class='STYLE1'>".$row['name']."</div></td>    <td   height='22' class='STYLE1'> <div align='center'>".$row['subject']."</div></td>    <td   height='22' class='STYLE1'> <div align='center'>".$row['teacher']."</div></td>	<td   height='22' class='STYLE1'> <div align='center'>".$row['zhicheng']."</div></td>  </tr> ";   $n++;   } ?></table> <p> </p><?php include "foot.php";?>
登录后复制

if($search)
{

这个if没有关闭,即少了 } 号

if($search)
{

这个if没有关闭,即少了 } 号 好,我看看

if($search)
{

这个if没有关闭,即少了 } 号 是加在48行后吗?我加了以后就变成这样了

是加在48行后吗?
 我不知道你的逻辑,你自己应该很清楚啊。

$search 和 $xuehao 你在哪定义的?

是加在48行后吗?
 我不知道你的逻辑,你自己应该很清楚啊。

$search 和 $xuehao 你在哪定义的? 不太清楚啊,因为这个代码老师给的让做修改……

最后缺了个分号


include "foot.php";?>

最后缺了个分号


include "foot.php";?> 有分号啊

……  楼主这错误看着太头晕,建议你用eclipse什么的去检查一下,丢的东西有点多啊

……  楼主这错误看着太头晕,建议你用eclipse什么的去检查一下,丢的东西有点多啊 说我的最后一行是语法错误,unexpected 'EOF'这是什么意思?


最后缺了个分号


include "foot.php";?> 有分号啊

你上面贴的代码里没有


……  楼主这错误看着太头晕,建议你用eclipse什么的去检查一下,丢的东西有点多啊 说我的最后一行是语法错误,unexpected 'EOF'这是什么意思?

你那少了一个括号的括回,仔细检查一下代码吧。

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号