Jump to content


Photo

ascending data from a table row? Need help.


  • Please log in to reply
2 replies to this topic

#1 sw0o0sh

sw0o0sh
  • Members
  • PipPipPip
  • Advanced Member
  • 151 posts
  • LocationMassachusetts

Posted 02 August 2006 - 09:45 PM

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.

<?

   $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";

} 



?>


#2 ItsWesYo

ItsWesYo
  • Members
  • PipPipPip
  • Advanced Member
  • 110 posts

Posted 02 August 2006 - 09:51 PM

Don't know if this will work xD

<?
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>";
}
?>

That should show all names in ABC order.

#3 sw0o0sh

sw0o0sh
  • Members
  • PipPipPip
  • Advanced Member
  • 151 posts
  • LocationMassachusetts

Posted 02 August 2006 - 09:56 PM

thanks it worked.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users