php读取数据库中表问题
运行结果如下图,貌似只有前24行有问题。如果读取数据库表正常,每一栏里应该显示数据库当中的内容。
<?php//######################课题详细信息########################## include "config.php"; include "header.php";?><title>课题详细信息</title><style type="text/css"><!--.STYLE1 { font-size: 16px; color: #FF0000;}.STYLE2 {font-size: 14px}.STYLE3 {font-size: 12px}--></style><p></p><?php $query="select * from $jiaoshi_table where id='".$id."'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query); $row=mysql_fetch_array($result);?><table width="700" border="1" align="center" cellpadding="0" cellspacing="1" class="text"> <!--DWLayoutTable--> <form name="form1" method="post" action="xiangxiziliao.php"> <tr bgcolor="#E4E4E4"> <td height="27" colspan="3"><span class="STYLE1 STYLE2">>>>课题信息</span></td> </tr> <tr> <td width="184" bgcolor="#FFFFFF"><div align="center" class="STYLE2"> <div align="right">课题编号:</div> </div></td> <td width="507" bgcolor="#FFFFFF" height="39"> <input type="text" name="id" size="28" value="<?php echo $row['id'] ?>" readonly="readonly"> </td> </tr> <tr> <td width="184" bgcolor="#E4E4E4"><div align="center" class="STYLE2"> <div align="right">课题名称:</div> </div></td> <td width="507" bgcolor="#E4E4E4" height="39"> <input type="text" name="subject1" size="45" value="<?php echo $row['subject'] ?>" readonly="readonly"> </td> </tr> <tr> <td width="184" bgcolor="#FFFFFF"><div align="center" class="STYLE2"> <div align="right">指导教师姓名:</div> </div></td> <td width="507" bgcolor="#FFFFFF" height="36"> <input type="text" name="teacher1" size="30" value="<?php echo $row['teacher'] ?>" readonly="readonly"> </td> </tr> <tr> <td width="184" bgcolor="#E4E4E4"><div align="center" class="STYLE2"> <div align="right">指导教师职称:</div> </div></td> <td width="507" bgcolor="#E4E4E4" height="41"> <input type="text" name="zhicheng1" size="25" value="<?php echo $row['zhicheng'] ?>" readonly="readonly"> </td> </tr> <tr> <td width="184" bgcolor="#FFFFFF"><div align="center" class="STYLE2"> <div align="right">教师的研究方向:</div> </div></td> <td width="507" bgcolor="#FFFFFF" height="41"> <input type="text" name="specialized1" size="25" value="<?php echo $row['specialized'] ?>" readonly="readonly"> </td> </tr> <tr> <td width="184" bgcolor="#E4E4E4"><div align="center" class="STYLE2"> <div align="right">课题专业代码:</div> </div></td> <td width="507" bgcolor="#E4E4E4" height="41"> <input type="text" name="code1" size="20" value="<?php echo $row['code'] ?>" readonly="readonly"> <span class="STYLE3"></span></td> </tr> <tr> <td width="184" bgcolor="#FFFFFF"><div align="center" class="STYLE2"> <div align="right">课题所需学生人数:</div> </div></td> <td width="507" bgcolor="#FFFFFF" height="41"> <input type="text" name="number1" size="20" value="<?php echo $row['number'] ?>" readonly="readonly"> <span class="STYLE3"></span></td> </tr> <tr> <td width="184" bgcolor="#FFFFFF"><div align="center" class="STYLE2"> <div align="right">课题简要说明:</div> </div></td> <td width="507" bgcolor="#FFFFFF" height="163"><label> <textarea name="introduction" cols="60" rows="10" readonly="readonly"><?php echo $row['beizhu'] ?></textarea> </label></td> </tr> </form></table><p></p><?php include "foot.php"?>
回复讨论(解决方案)
$query="select * from $jiaoshi_table where id='".$id."'";
修改为:
$query="select * from $jiaoshi_table where id='$id'";
$query="select * from $jiaoshi_table where id='".$id."'";
修改为:
$query="select * from $jiaoshi_table where id='$id'"; 我刚刚照你的方法试了,还是不行啊
你的 $id 在哪里赋值的?
总不会在 config.php 或 header.php 里吧?
同楼上大神,还有难道是我记错了,$jiaoshi_table不用引号的么?
你的 $id 在哪里赋值的?
总不会在 config.php 或 header.php 里吧?
<?php $n=0; $query=mysql_query("select count(*) as sm from jiaoshi"); mysql_query("set names 'GB2312'"); $row=mysql_fetch_array($query); $count=$row['sm']; if(empty($offset)) {$offset=0;} echo $offset; $query=mysql_query("select * from jiaoshi order by teacher asc limit $offset,$list_num") or die ("fail"); mysql_query("set names 'GB2312'"); while($row=mysql_fetch_array($query)){ if(($n%2)!='0'){ echo "<tr bgcolor=#FFFFff>";} else{ echo "<tr bgcolor=#E4E4E4>"; } if($row['surplus']==0) $ss="不可选"; else $ss="可选"; echo" <td height='22' class='STYLE1'> <div align='center'>".$row['id']."</div></td> <td height='22'> <div align='center' class='STYLE1'>".$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> <td height='22' class='STYLE1'> <div align='center'>".$row['number']."</div></td> <td height='22' class='STYLE1'> <div align='center'>".$row['xuehao']."</div></td> <td height='22' class='STYLE1'> <div align='center'>".$ss."</div></td> <td height='22' class='STYLE1'><div align='center'> <a href=xiangxiziliao.php?id=".$row['id'].">查看</a></div></td> </tr> "; $n++; } ?>
LZ你是想通过URL把ID传进来?
那应该用$_GET方法来实现
LZ你是想通过URL把ID传进来?
那应该用$_GET方法来实现 谢谢~能告诉我具体语句吗?因为我还是个新手
你是指 查看
那么 get 方式的 id 要用 $_GET['id'] 访问,而你却直接 $id 了,那怎么行呢?
至少需要有 $id = $_GET['id']; 才可以
你的URL点击进来的时候应该是这样子吧?
xiangxiziliao.php?id=1
然后
if(isset($_GET['id'])&&$_GET['id']!=''){
echo $_GET['id'];
}
测试下
更详细的参考w3school吧
你是指 查看
那么 get 方式的 id 要用 $_GET['id'] 访问,而你却直接 $id 了,那怎么行呢?
至少需要有 $id = $_GET['id']; 才可以 那具体应该如何改呢?
<?php $id = $_GET['id']; $query="select * from $jiaoshi_table where id='".$id."'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query);....
<?php $id = $_GET['id']; $query="select * from $jiaoshi_table where id='".$id."'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query);....

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

在PHP中,應使用password_hash和password_verify函數實現安全的密碼哈希處理,不應使用MD5或SHA1。1)password_hash生成包含鹽值的哈希,增強安全性。 2)password_verify驗證密碼,通過比較哈希值確保安全。 3)MD5和SHA1易受攻擊且缺乏鹽值,不適合現代密碼安全。

PHP類型提示提升代碼質量和可讀性。 1)標量類型提示:自PHP7.0起,允許在函數參數中指定基本數據類型,如int、float等。 2)返回類型提示:確保函數返回值類型的一致性。 3)聯合類型提示:自PHP8.0起,允許在函數參數或返回值中指定多個類型。 4)可空類型提示:允許包含null值,處理可能返回空值的函數。

PHP主要是過程式編程,但也支持面向對象編程(OOP);Python支持多種範式,包括OOP、函數式和過程式編程。 PHP適合web開發,Python適用於多種應用,如數據分析和機器學習。

PHP適合網頁開發和快速原型開發,Python適用於數據科學和機器學習。 1.PHP用於動態網頁開發,語法簡單,適合快速開發。 2.Python語法簡潔,適用於多領域,庫生態系統強大。

PHP起源於1994年,由RasmusLerdorf開發,最初用於跟踪網站訪問者,逐漸演變為服務器端腳本語言,廣泛應用於網頁開發。 Python由GuidovanRossum於1980年代末開發,1991年首次發布,強調代碼可讀性和簡潔性,適用於科學計算、數據分析等領域。

PHP在現代化進程中仍然重要,因為它支持大量網站和應用,並通過框架適應開發需求。 1.PHP7提升了性能並引入了新功能。 2.現代框架如Laravel、Symfony和CodeIgniter簡化開發,提高代碼質量。 3.性能優化和最佳實踐進一步提升應用效率。

PHP的核心優勢包括易於學習、強大的web開發支持、豐富的庫和框架、高性能和可擴展性、跨平台兼容性以及成本效益高。 1)易於學習和使用,適合初學者;2)與web服務器集成好,支持多種數據庫;3)擁有如Laravel等強大框架;4)通過優化可實現高性能;5)支持多種操作系統;6)開源,降低開發成本。

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip
