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);....

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
