jasonc Posted September 5, 2010 Share Posted September 5, 2010 I have a table of data and wish to only display the `name` column on the page. I have tried a few methods looking at php.net site but just can not seem to get this right and show only the `name` column, there are about 10 names so far but only the first of each name is showing in the selection pull down menu? $res = db_query("SELECT `name` FROM `client_names` WHERE `customer_id` = '". $customer_id ."'"); $res_array = mysql_fetch_row($res); //$maincount = mysql_num_rows($res); foreach ($res_array as $res2) { $form_text .= '<option value="'.$res2['name'].'"' . $selected . '>'.$res2['name'].'</option>'; } Link to comment https://forums.phpfreaks.com/topic/212609-how-to-display-only-one-column-of-results/ Share on other sites More sharing options...
Pikachu2000 Posted September 5, 2010 Share Posted September 5, 2010 $query = "SELECT `name` FROM `client_names` WHERE `customer_id` = $customer_id"; // assuming $customer_id is an integer $query = mysql_query( $query ); // can add or die( mysql_error() ) if necessary for debugging query execution while( $array = mysql_fetch_assoc($result) ) { // returns an associative array echo $array['name'] . '<br />'; // echo each array element while the condition is true } Link to comment https://forums.phpfreaks.com/topic/212609-how-to-display-only-one-column-of-results/#findComment-1107573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.