0

how do I make this display the most recent users first?

<?php

$host="mysql13.000webhost.com"; // Host name 
$username="a2670376_Users"; // Mysql username 
$password="PASSWORD"; // Mysql password 
$db_name="a2670376_Pass"; // Database name 
$tbl_name="passes"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// select record from mysql 
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<table background='https://lh6.ggpht.com/DFABQFuYSXLBiB6qlvDPfOONOUxCiwM6_S-    dHnjW82iognQToTkORsy7RVXsAz0Y23w=w705' width='50%'>
<tr>
<th align='left'>Submition</th><th align='center'>ScreenName</th><th     align='right'>Password</th>
</tr>
<tr>
<th align='left'>
<hr color='lime' width='100%'/>
</th>
<th align='center'>
<hr color='lime' width='100%'/>
</th>
<th align='right'>
<hr color='lime' width='100%'/>
</th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>

<tr>
<td background='transparent' align='left'><i><b><? echo $rows['id']; ?></b></i></td>
<td background='transparent' align='center'><i><b><? echo $rows['username']; ?></b></i>    </td>
<td background='transparent' align='right'><i><b><? echo $rows['password']; ?></b></i>   </td>
</tr>

<?php
// close while loop 
}
?>

</table>

<?php
// close connection; 
mysql_close();
?>
<center>

so when this is ran on my website it shows it like this

1 username password

2 username password

3 username password

I want it to show like this

3 username password

2 username password

1 username password

the most recent first and I cant seem to figure it out

please don't post things like use mysqli or its not safe I know that and I will fix it once I get it to work corectly

1 Answer 1

4

change your query to:

// select record from mysql 
$sql="SELECT * FROM $tbl_name order by id desc";
Sign up to request clarification or add additional context in comments.

1 Comment

@user1837896 if Habibillah's answer solved your problem, click the tick mark from the left side of this post and accept the answer...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.