Search the Community
Showing results for tags 'fetch_array()'.
-
I'm using PHP 5.3.13. I am just using a very simple query to grab one column of results from a table. I would like to fetch them and then iteratively add them to a dropdown menu. I am trying to understand these methods/functions and seem to be missing something. My research on Google didn't give me any indication of what I'm doing wrong. I start with one of the simplest queries possible, which I know will return a data set as I have tested it in mysqladmin. The problem arises when I try to call the method on the mysqli_result object. $query = "SELECT `artist` FROM `bands`;"; $result = $mysqli->query($query); $bandArr = $result->fetch_all(); The error I'm getting from the above code is: Fatal error: "Call to undefined method mysqli_result::fetch_all()..." I researched this error and read somewhere that you need mysqlnd. Is that true? Do I need to look into my PHP configuration to get this to work? Is it worth it for this task? Then I tried fetch_array... $query = "SELECT `artist` FROM `bands`;"; $result = $mysqli->query($query); $bandArr = $result->fetch_array(MYSQLI_NUM); printf("%s\n%s", $bandArr[0], $bandArr[1]); And the above code for some reason returns an array with only one item, and this error: "Notice: Undefined offset: 1 in..." What am I missing here? Again, all I want is a small result set from one column which can be iterated and each value added to a drop down menu. Thoughts? Suggestions? Thanks in advance for any help you can offer...
- 4 replies
-
- mysqli
- fetch_all()
-
(and 1 more)
Tagged with: