Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 更改数据库中显示名称的顺序_Php_Html_Mysql - Fatal编程技术网

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

Php 更改数据库中显示名称的顺序,php,html,mysql,Php,Html,Mysql,我有一个显示登录用户名称的站点。我想在页面上首先显示新添加的名称。例如,当我在stackoverflow上发布这个问题后,我的名字会首先显示在主页上 我有一个接受名称的表单和一个显示名称的display.php: <?php mysql_connect('mysql', 'Usere', 'Pass'); mysql_select_db('a5803761_add'); $query =mysql_query('select * from addname'); whil

我有一个显示登录用户名称的站点。我想在页面上首先显示新添加的名称。例如,当我在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              stack
stack               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>';
}

?>


这一定对你有用

试试这个,希望这对你有用

while( $row = mysql_fetch_assoc($query) )
   {
        $name1=  $row['name'];
        $url1=  $row['url'];        
    }
<div style="min-width:300px;height:100px;border:red 5px;float:left;"><a href="<?php echo $url1; ?>"><?php echo $name1; ?></a></div>
while($row=mysql\u fetch\u assoc($query))
{
$name1=$row['name'];
$url1=$row['url'];
}

按id排序DESC
->下一次,请尝试关联(这些空格与问题无关,但您的数据库结构是)意味着我保存用户登录时所做操作的数据