Jump to content

mySQLi return array


N-Bomb(Nerd)

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.