热搜:NVER node 开发 php

php查询数据库表问题

2024-09-11 23:25:01
php查询数据库表问题

学生课题查询<?php//######################学生查询所选课题########################## include "config.php"; include "header.php";?> <?if($search){  if ($xuehao=="")  {	echo"

请填写您的学号!

"; echo ""; 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"

你还没有注册,或者你的输入有误,请重新输入!

"; echo ""; 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"

你还没有选择课题,请去选题!

"; echo ""; exit; } ?> <? $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 "";} else{ echo ""; } echo" "; $n++; } ?>

学生学号

学生姓名 课题名称 指导教师 职称
".$row['xuehao']." ".$row['name']." ".$row['subject']." ".$row['teacher']." ".$row['zhicheng']."

<?php include "foot.php";?>

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


回复讨论(解决方案)

你截的图看看     

你截的图看看     

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

你没开启段标签
<?if($search){ if ($xuehao=="") {
改成<?php if($search){ if ($xuehao=="") {

你没开启段标签
<?if($search){ if ($xuehao=="") {
改成<?php if($search){ if ($xuehao=="") { 谢谢~我试一下

你没开启段标签
<?if($search){ if ($xuehao=="") {
改成<?php if($search){ if ($xuehao=="") { 不行呀,我开启了段标签后,就成这样了

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

你代码到91行之前都在执行,你就不能开全了吗
<? $n=0; $query=mysql_query("select * from $jiaoshi
这里还有一个,你没改成<?php吧 对天发誓我改啦~~

学生课题查询<?php//######################学生查询所选课题########################## include "config.php"; include "header.php";?><?phpif($search){  if ($xuehao=="")  {	echo"

请填写您的学号!

"; echo ""; 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"

你还没有注册,或者你的输入有误,请重新输入!

"; echo ""; 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"

你还没有选择课题,请去选题!

"; echo ""; exit; } ?> <?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 "";} else{ echo ""; } echo" "; $n++; } ?>

学生学号

学生姓名 课题名称 指导教师 职称
".$row['xuehao']." ".$row['name']." ".$row['subject']." ".$row['teacher']." ".$row['zhicheng']."

<?php include "foot.php";?>

if($search)
{

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

if($search)
{

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

if($search)
{

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

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

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

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

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

最后缺了个分号

<?php

include "foot.php";?>

最后缺了个分号

<?php

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

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

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


最后缺了个分号

<?php

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

你上面贴的代码里没有


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

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