nadz Posted October 8, 2006 Share Posted October 8, 2006 hi, i need an sql query i can execute in a table so that it only shows 2 of the fields. any help would be appreciated. thankyou. Link to comment https://forums.phpfreaks.com/topic/23347-sql-query-to-show-only-some-fields/ Share on other sites More sharing options...
alpine Posted October 8, 2006 Share Posted October 8, 2006 In php:[code]<?php$select = mysql_query("SELECT field_1, field_2 FROM table") or die(mysql_error());while($col = mysql_fetch_array($select, MYSQL_ASSOC){foreach($col as $fieldname => $value){${$fieldname} = $value;}echo $field_1;echo $field_2;}?>[/code] Link to comment https://forums.phpfreaks.com/topic/23347-sql-query-to-show-only-some-fields/#findComment-105831 Share on other sites More sharing options...
nadz Posted October 8, 2006 Author Share Posted October 8, 2006 hi, thanks alot for your help ;)unfortunately im getting errors. im using phpmyadmin, the 2 fields i want to see are "members" and "date" in the table "users". i hope this helps.thanks again for the help. Link to comment https://forums.phpfreaks.com/topic/23347-sql-query-to-show-only-some-fields/#findComment-105992 Share on other sites More sharing options...
fenway Posted October 9, 2006 Share Posted October 9, 2006 DATE is a reserved keyword -- change your column name; in the meanwhile, you can use `date`. Link to comment https://forums.phpfreaks.com/topic/23347-sql-query-to-show-only-some-fields/#findComment-106102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.