我想做一个页面显示一些人名,每个人名都有id,用户点击人名则进入人名具体信息。
问题是现在点击的信息不能识别,无法通过id的传递进入人名的具体信息,
代码如下,希望高手帮忙,谢谢<html>
<head>
<title>Student Info</title>
</head>
<body>
<?php
function usetable($result)
{print "<h1>Student Infornamtion</h1>\n";
print "\n<table>\n<tr>\n" .
"\n\t<th>ID</th>" .
"\n\t<th>Last Name</th>" .
"\n\t <th>First Name</th>" .
"\n</th>"; if($conn = mysql_connect('localhost',DB_USER_NAME, DB_PASSWORD)){ print "<p>Successfully connected to MySQL!</p>"; mysql_select_db("clin2",$conn);
$sql=mysql_query("select userID from user");
$a=$myrow[userID];
$result = mysql_query("select LName, FName from user");
while($row = @ mysql_fetch_row($result)){
print "\n<tr>";
foreach($row as $data)
print "\n\t<td><a href=test3.php?a=$a> {$data} </a></td>";
print "\n</tr>";
}
print "\n</table>\n"; mysql_close();
} else {
print '<p style="color:red;">Could not connect to MySQL.</p>';
}
}
usetable($result);?>
</body>
</html>接受的代码如下<html>
<head>
<title>Student Info</title>
</head>
<body><?php
if($conn = mysql_connect('localhost',DB_USER_NAME, DB_PASSWORD)){ print "<p>Successfully connected to MySQL!</p>"; mysql_select_db("clin2",$conn);$sql="select * from user where id = $_GET[a]"; print "\n<tr>";
print "\n\t<td> {$sql} </td>";
print "\n</tr>";?>
</body>
</html>
问题是现在点击的信息不能识别,无法通过id的传递进入人名的具体信息,
代码如下,希望高手帮忙,谢谢<html>
<head>
<title>Student Info</title>
</head>
<body>
<?php
function usetable($result)
{print "<h1>Student Infornamtion</h1>\n";
print "\n<table>\n<tr>\n" .
"\n\t<th>ID</th>" .
"\n\t<th>Last Name</th>" .
"\n\t <th>First Name</th>" .
"\n</th>"; if($conn = mysql_connect('localhost',DB_USER_NAME, DB_PASSWORD)){ print "<p>Successfully connected to MySQL!</p>"; mysql_select_db("clin2",$conn);
$sql=mysql_query("select userID from user");
$a=$myrow[userID];
$result = mysql_query("select LName, FName from user");
while($row = @ mysql_fetch_row($result)){
print "\n<tr>";
foreach($row as $data)
print "\n\t<td><a href=test3.php?a=$a> {$data} </a></td>";
print "\n</tr>";
}
print "\n</table>\n"; mysql_close();
} else {
print '<p style="color:red;">Could not connect to MySQL.</p>';
}
}
usetable($result);?>
</body>
</html>接受的代码如下<html>
<head>
<title>Student Info</title>
</head>
<body><?php
if($conn = mysql_connect('localhost',DB_USER_NAME, DB_PASSWORD)){ print "<p>Successfully connected to MySQL!</p>"; mysql_select_db("clin2",$conn);$sql="select * from user where id = $_GET[a]"; print "\n<tr>";
print "\n\t<td> {$sql} </td>";
print "\n</tr>";?>
</body>
</html>
解决方案 »
- 刚做好的IT网址站--希望大家能用得着-- www.it01.net
- 这样查看源文件,看不到小说的内容是怎么样实现的啊?
- 用PHP处理表单的一个很大的疑问,不知道错在哪。。。在线等!!!
- PHP找人合作开发项目
- 请教!我想对<!--beginunit name=xxx--!>内容<!--endunit--!>进行替换。
- 偶发现很多提供短信发送业务的网站都是用 PHP写的,这说明 php在短信服务这方面还是得到很多开发商认可的,不知大家怎么看
- 怎样用php新建一数据表?
- 请教,有没有办法读取FTP的进站欢迎信息将其显示在网页上
- 大家帮帮我好吗?
- js 里面引用PHP返回的数据,为什么不会自己更新呢?
- 关于PHP连接MSSQL2008问题
- php二维数组赋值问题
$a=$myrow[userID]; $result = mysql_query("select LName, FName from user"); while($row = @ mysql_fetch_row($result)){
print "\n <tr>";
foreach($row as $data)
print "\n\t <td> <a href=test3.php?a=$a> {$data} </a> </td>";
print "\n </tr>";
}
print "\n </table>\n";
这段代码有问题.
我猜测,这个id,LName,FName应该是一一对应的才对,所以你前两句等于是无效的.
$result = mysql_query("select userID LName, FName from user"); while($row = @ mysql_fetch_row($result)){
$userid = $row[0];
print "\n <tr>";
foreach($row as $data)
print "\n\t <td> <a href=test3.php?a=$userid> {$data} </a> </td>";
print "\n </tr>";
}
$userid = $row[0];
unset($row[0]);
print "\n <tr>";
foreach($row as $data)
print "\n\t <td> <a href=test3.php?a=$userid> {$data} </a> </td>";
print "\n </tr>";
}
<head>
<title>Student Info</title>
</head>
<body>
<?php
function usetable($result)
{print "<h1>Student Infornamtion</h1>\n";
print "\n<table>\n<tr>\n" .
"\n\t<th>Last Name</th>" .
"\n\t <th>First Name</th>" .
"\n</th>"; if($conn = mysql_connect('localhost',DB_USER_NAME, DB_PASSWORD)){ print "<p>Successfully connected to MySQL!</p>"; mysql_select_db("clin2",$conn);
$result = mysql_query("select LName, FName from user");
$res = mysql_query("select userID from user"); while($row = @ mysql_fetch_row($result)){
$rowa = mysql_fetch_row($res);
$userID = $rowa[0];
print "\n <tr>";
foreach($row as $data)
print "\n\t <td> <a href=test3.php?ID=$userID> {$data} </a> </td>";
print "\n </tr>";
}
mysql_close();
} else {
print '<p style="color:red;">Could not connect to MySQL.</p>';
}
}
usetable($result);?>
</body>
</html>但是接受页显示不出结果,不知道什么问题,
接受页如下<html>
<head>
<title>Student Info</title>
</head>
<body><?php
if($conn = mysql_connect('localhost',DB_USER_NAME, DB_PASSWORD)){ print "<p>Successfully connected to MySQL!</p>"; mysql_select_db("clin2",$conn);$sql=mysql_query("select * from user tablename where ID = $_GET[ID]"); $array=@mysql_fetch_array($sql);echo $array[ID];}
?>
</body>
</html>
大概是这个样子吧