php 数据库里面的信息 超链接

php 数据库里面的信息 超链接,第1张

提高效率建议增加一个ID字段设置值为自动编号

//page1.php

$row=mysql_query("select * from information order by id desc")

while($rs=mysql_fetch_array($row)){

echo '<a href="XX.php?id='.$rs['id'].'">'.$rs['title'].'</a>'

echo '<br/>'

}

以上是输出列表

//page2.php

$id = isset($_GET['id']) ? $_GET['id'] : 0

$row = mysql_query("select * from information where id ={$id}")

$rs = mysql_fetch_array($row)

echo $rs['detail']

//以上输出内容

// 这个很简单的啊.

mysql_connect()

mysql_select_db()

mysql_query('set names utf8')

$sql = 'SELECT * FROM tablename'

$r = mysql_query($sql)

if (!$r) exit('Get Data Fail...')

echo '<table><th>标题</th><th>姓名</th><th>时间</th>'

while (true) {

    $data = mysql_fetch_assoc($r)

    if ($data) {

        echo '<tr>'

            echo '<td>' . $data['title'] . '</td>'

            echo '<td>' . $data['name'] . '</td>'    // 你的数据库没有字段 name

            echo '<td>' . $data['start_time'] . '</td>'

            echo '<td>

                <a href="index?tehere-detail-' . $data['id'] . '.html"></a>

            </td>' // 这个超链接

        echo '</tr>'

    } else {

        break

    }

}

echo '</table>'


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9844498.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-02
下一篇 2023-05-02

发表评论

登录后才能评论

评论列表(0条)

保存