Jump to content

ascending data from a table row? Need help.


sw0o0sh

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]
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.