N-Bomb(Nerd) Posted March 9, 2010 Share Posted March 9, 2010 Hi, I'm trying to write a function to read my database and return an array of names. I'm not very good because I've never really dealt with databases before.. here's the code I got so far. <?php function NameList() { $query = "SELECT name FROM people"; if ($NameQuery = $this->db->prepare($query)) { $NameQuery->execute(); while ($NameQuery->fetch()) { // something here I assume.. } return $TheWholeListOfNames; } } ?> I'm not just running into a problem and asking for help. I've actually tried searching this up and have been trial and error now for the last two hours.. finally gave up and asked for help. Not quite sure where to go from here... would appreciate some help. Thanks. Link to comment https://forums.phpfreaks.com/topic/194603-mysqli-return-array/ Share on other sites More sharing options...
DCRepairs Posted March 9, 2010 Share Posted March 9, 2010 Try this <?php $query1 = "SELECT * FROM people"; $result1 = mysql_query($query1); while($row1 = mysql_fetch_array($result1, MYSQL_ASSOC)) { echo "$row1['name']"; } ?> Format the above code to fit in a table if you wish. Link to comment https://forums.phpfreaks.com/topic/194603-mysqli-return-array/#findComment-1023484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.