Jump to content

Archived

This topic is now archived and is closed to further replies.

sw0o0sh

ascending data from a table row? Need help.

Recommended Posts

Hi, I have a table in my SQL database called "chaoworld_a" without quotes.
In it, I have a row called "Name" without quotes.

I am trying to make a page where the PHP grabs all Name entries from chaoworld_a and descends it.

Say a Name in table located on the database is Item 1, and Item 2,

I am trying to make a page there would list it..

So on a seperate page it'd say ..

Item 1
Item 2
So on.

I don't need a specific order, but using order by Name so it is in alphabetical order would be a plus. I need to know both methods..

I suck really bad at PHP, and this code I made is very wrong.. a Fix on how I would do what I am trying to do would be nice.

[code]
<?

  $conn = mysql_connect("localhost","davessonicsite","password");
  mysql_select_db(davessonicsite) or die(mysql_error());



$Name = mysql_query("SELECT Name * from chaoworld_a order by Name asc");
while ($Name = mysql_fetch_array($Name)){

echo "$Name";

}



?>
[/code]

Share this post


Link to post
Share on other sites
Don't know if this will work xD

[code]
<?
mysql_connect("localhost","user","password");
mysql_select_db("your_database");
$result = mysql_query("SELECT * FROM table_name  ORDER BY Name");
while($r=mysql_fetch_array($result))
{
  $name=$r["Name"]; // follow that format
 
  echo "$name<br>";
}
?>
[/code]

That should show all names in ABC order.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.