View Full Version : Create array from sql data, question.

11-17-2010, 11:58 AM
Hello to all,

I have this script it's part of a login system and it puts the values USER & PASSWORD in array for further authentication:

'User1' => '123456',
'User2' => '789101'

I want to populate this array from a sql table named access that has username and password databases.

how can I do this? I think i know a way of doing it but I have a problem with the hiding the last comma in the array.

11-17-2010, 12:43 PM
What have you tried? Show us what you have and we should be able to help.

11-17-2010, 03:38 PM
It's something like this, but this is totaly wrong.

$users_result = mysql_query("SELECT * FROM access");
while($row = mysql_fetch_array($users_result))
echo '$row' => '$row[password]';

I want it to populate the results in here:


11-17-2010, 03:50 PM
Instead of echoing, insert the values into your login array, something like this:

$users_result = mysql_query("SELECT * FROM access");
while($row = mysql_fetch_array($users_result)){

Then, for debugging purposes, you can view what is in your login array like so:


11-17-2010, 04:04 PM
Perfect, just learnt a very important thing.

Works fine.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum