0

Hi guys, I am in need of a code that can put the values of a column in an array. EG:
I have a database with usernames, and I wanted each username to be stored in an array automatically, so each time the page is viewed it runs the code and adds all the users in an array.
I am trying to use this code for my site
http://www.w3schools.com/Ajax/ajax_source.asp
Scroll to the bottom, where the code is for php. Is it possible to the array like that?

Thanks,
-Toxikr3

EDIT: oh oh! I am getting an idea! Please tell me if I am on the right track, you use a while loop to get the usernames and add them each to the array while incrementing the array number... if that is the right way, will someone help me come up with the code?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Toxikr3
0

Your php code will be something like this, though the precise query commands may differ:

$query = "your sql here";
$qry_result = mysql_query($query) or die(mysql_error());

$myArray = array();
while($row = mysql_fetch_array($qry_result)){
	$myArray[] = $row['userName'];
}

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.