Ph0enix Posted May 10, 2006 Share Posted May 10, 2006 Hi, i know how to select a row of data by using this: $sql = "SELECT * FROM table ORDER BY id DESC";But how do i select a whole column, so i would have the users name and their information.And i would like for it to be displayed just simple like this:Ph0enix England 14/03/1990 Male.Could anyone help me to do this please?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/9514-selecting-a-column/ Share on other sites More sharing options...
toplay Posted May 10, 2006 Share Posted May 10, 2006 Click on the [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=31047&view=findpost&p=153359\" target=\"_blank\"]PHP F.A.Q.[/a] link. Find and read the [b]MySQL Data Retrieval[/b] section for example code of getting data from MySQL with error checking. Quote Link to comment https://forums.phpfreaks.com/topic/9514-selecting-a-column/#findComment-35109 Share on other sites More sharing options...
Ph0enix Posted May 10, 2006 Author Share Posted May 10, 2006 wow theres a lot of stuff there. Thanks But i find things easier to take in if you could tell me and give me an example cause im a noob.[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]PHP Newbie Help[/quote]Could you explain it please? Quote Link to comment https://forums.phpfreaks.com/topic/9514-selecting-a-column/#findComment-35110 Share on other sites More sharing options...
.josh Posted May 11, 2006 Share Posted May 11, 2006 a row goes this way <--------- -------------->a column goes this way /\||||\/this query:$sql = "SELECT * FROM table ORDER BY id DESC";will select everything both ways in your table, in reverse numerical order, ordered by id.if you want to select just one row, based on the user's id, then do this:select * from table where userid = '1'this will, for instance, select all the information where the user's id is 1. the idea is to put a variable in place of the 1, in order to dynamically retrieve data from the database. for instance:$id = 1;$sql = "select * from table where userid = '$id'";the "*" is a wildcard that selects all the column data in the row you are selecting. you can select individual colums by naming them instead of the * like so (assuming you have a column named username):$sql = "select username from table where userid = '$id'"; Quote Link to comment https://forums.phpfreaks.com/topic/9514-selecting-a-column/#findComment-35175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.