Home > php教程 > php手册 > php mysql查询数据

php mysql查询数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-02 09:14:21
Original
1265 people have browsed it

<?php
//连接数据库教程
$link_id = mysql教程_connect("localhost", "root", "") or die("连接失败");
if ($link_id) {
    //选择数据库
    mysql_select_db("my_test");
    //以上为头部数据库连接部分,为以下公用的部分。
    if (!$_GET[id]) {
        //显示用户列表
        $sql = "select * from userinfo";
        $result = mysql_query($sql);
        echo "<TABLE border=1> 
<TR> 
 <TD>编号</TD> 
 <TD>用户名称</TD> 
 <TD>性别</TD> 
 <TD>年龄</TD> 
 <TD>注册时间</TD> 
 <TD>详细信息</TD> 
</TR>";
        while ($row = mysql_fetch_array($result)) {
            echo "<TR> 
 <TD>" . $row[id] . "</TD> 
 <TD>" . $row[username] . "</TD> 
 <TD>" . $row[gender] . "</TD> 
 <TD>" . $row[age] . "</TD> 
 <TD>" . $row[regdate] . "</TD> 
 <TD><a href=query.php?id=" . $row[id] . ">查看</a></TD> 
</TR>"; //开源代码phprm.com
            
        }
        echo "</TABLE>";
    } else {
        //显示指定用户的详细信息
        $sql = "select * from userinfo where id=" . $_GET[id];
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result);
        echo "编号:" . $row[id] . "<br>用户名:" . $row[username] . "<br>性别:" . $row[gender] . "<br>年龄:" . $row[age] . "<br>注册时间:" . $row[&#39;regdate&#39;];
        echo "<br><br><br><a href=query.php>继续查询</a>";
    }
} //end if
Copy after login


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template