gpt4 book ai didi

php - 更改数据库中显示名称的顺序

转载 作者:行者123 更新时间:2023-11-29 00:03:54 24 4
gpt4 key购买 nike

我有一个显示登录用户名称的网站。我想在页面上首先显示新添加的名称。例如在我将这个问题发布到 stackoverflow 上之后,我的名字将首先显示在主页上。

我有一个接受名字的表单和一个显示名字的 display.php 是:

<?php

mysql_connect('mysql', 'Usere', 'Pass');
mysql_select_db('a5803761_add');
$query =mysql_query('select * from addname');

while( $row = mysql_fetch_assoc($query) )
{
echo '<div style="min-width:300px;height:100px;border:red 5px;float:left;">''<a href='.$row['url'].>'.$row['name'].'</a>''</div>';
}

?>

这显示名称如下:

Mark                james             Bond   
bill gates

现在,当我将堆栈名称添加到我的数据库时,它显示如下:

Mark                james              Bond   
bill gates stack

但我想像这样先显示堆栈:

stack               Mark              james   
bond bill gates

假设我的数据库中有 010000000 个名字,我想首先在网页上显示最新添加的名字

最佳答案

你需要尝试这段代码

<?php

mysql_connect('mysql', 'Usere', 'Pass');
mysql_select_db('a5803761_add');
$query =mysql_query('select * from addname order by ID DESC limit 1');


while( $row = mysql_fetch_assoc($query) )
{

echo '<div style="min-width:300px;height:100px;border:red 5px;float:left;"><a href="'.$row['url'].'">'.$row['name'].'</a></div>';
}

?>

这一定对你有用

关于php - 更改数据库中显示名称的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28406356/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com