How to sort data from the database from 1 to 10 again $ query & nbsp; select & nbsp; * & nbsp; from & nbsp; software & nbsp; order & nbsp; by & nbsp; cnet_total_downloads & nbsp; limit & nbsp; 10; $ result & nbsp; mysql_query (how to sort from 1 to 10 after $ qu is read from the database
$query = "select * from software order by cnet_total_downloads limit 10";
$result = mysql_query($query) OR die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "X.".$row['software_name'];
}
The expected result is how the above X is changed to 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
Final Display
1.
2. B
3. c
.
.
.
10. Z
How to implement this 1 to 10
Share: More
------ Solution --------------------
$query = "select * from software order by cnet_total_downloads limit 10";
$result = mysql_query($query) OR die(mysql_error());
while($row = mysql_fetch_array($result))
{
static $i=1;
echo "$i.".$row['software_name'];
$i++;
}
Try to see if it works.