fisher7679 Posted July 20, 2013 Share Posted July 20, 2013 I have some code that returns a single column in a table, but I need to pull all columns........Can some one point me in the right direction to do this? Here is the code I am using to pull the single column $query = "SELECT * FROM `$table_name` WHERE uuid = '$uuid'"; $result = mysqli_query($dbh,$query); if (!$result) { echo 'Could not run query: ' . mysqli_error($dbh); } else { while ($result_list = mysqli_fetch_array($result, MYSQL_ASSOC)) echo ("uuid: ".$result_list["owner"]); } mysqli_close($dbh); Thanks to anyone who can help. EDIT: I should add I assume it is in the .$result_list[] area. I have tried several different things but nothing has worked so far. Link to comment https://forums.phpfreaks.com/topic/280331-help-understanding-how-to-get-data-from-mysql-with-php/ Share on other sites More sharing options...
requinix Posted July 20, 2013 Share Posted July 20, 2013 $result_list already has all the columns. See where it says "owner"? That's the column name. Link to comment https://forums.phpfreaks.com/topic/280331-help-understanding-how-to-get-data-from-mysql-with-php/#findComment-1441444 Share on other sites More sharing options...
fisher7679 Posted July 20, 2013 Author Share Posted July 20, 2013 Thank requinix! Right now it is echoing only the column "owner", how do I get it to echo all the columns for that table entry that I am looking at? Link to comment https://forums.phpfreaks.com/topic/280331-help-understanding-how-to-get-data-from-mysql-with-php/#findComment-1441446 Share on other sites More sharing options...
requinix Posted July 20, 2013 Share Posted July 20, 2013 foreach over $result_list. while ($result_list = mysqli_fetch_array($result, MYSQL_ASSOC)) { foreach ($result_list as $column => $value) { echo $column . " = " . $value . "<br/>\n"; } } Link to comment https://forums.phpfreaks.com/topic/280331-help-understanding-how-to-get-data-from-mysql-with-php/#findComment-1441449 Share on other sites More sharing options...
fisher7679 Posted July 20, 2013 Author Share Posted July 20, 2013 Thanks! Link to comment https://forums.phpfreaks.com/topic/280331-help-understanding-how-to-get-data-from-mysql-with-php/#findComment-1441517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.