fisher7679 Posted July 20, 2013 Share Posted July 20, 2013 (edited) 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. Edited July 20, 2013 by fisher7679 Quote 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. Quote 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? Quote 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"; } } Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.