PHP基础数据库链接帮助 [英] PHP basic database link help

查看:97
本文介绍了PHP基础数据库链接帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从数据库中获取字段,例如。 名称,然后使用它作为链接,从数据库本身显示有关该名称的更多信息
i used -

i want to fetch a field from database eg. "name" and then use it as a link to display further info about that name from the database itself i used -

while($re=mysql_fetch_array($result))
  {

echo"<a href=\"test.php?id=1\">{$re["name"]}'</a>'";

    }

但我希望从中获取每个'name'条目数据库被分配不同的ID像 -
adam id = 1
chris id = 2
所以在下一页我可以获取该ID并相应地显示内容。
请帮忙。

but i want that each 'name' entry when fetched from database be assigned different id like- adam id=1 chris id=2 so that in the next page i can GET that id and display contents accordingly. please help.

推荐答案

编辑当前示例以保持这样的计数:

Editing your current example to keep a count like this:

$id = 0;

while($re=mysql_fetch_array($result)) {
     $id++;
     echo"<a href=\"test.php?id={$id}\">{$re["name"]}'</a>'";
}

这篇关于PHP基础数据库链接帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆