-4
$namesSelect = "SELECT username FROM users";  
$names = mysql_query($namesSelect);
$nameCheck = mysql_fetch_array($names)

This selects all names from the users table and sets them to the array $names.

What I need to do is look through this array using javascript, to find if the name that the user has entered matches. I have no idea where to start with this, so any help would be appreciated.

5
  • 2
    I'm sorry but what you have said just makes no sense Commented Feb 2, 2012 at 21:18
  • How many users are expected to be in the database? Is this less than 100, or maybe rather more than 100,000? Commented Feb 2, 2012 at 21:20
  • You need to use Ajax. Your javascript function would call a PHP page (with ajax) that runs the MySql query and returns the results. Then you can process those results with javascript. Commented Feb 2, 2012 at 21:20
  • Could you please at least search the internet for what Javascript is before asking here? The simple answer is: not possible, since PHP is server-side and javascript is client-side. (Except if you're trying to go really exotic, but that doesnt seem to be the case.) Commented Feb 2, 2012 at 21:20
  • This is impossible. Read up on AJAX. Commented Feb 2, 2012 at 21:21

1 Answer 1

4

You're approaching this wrong.

Have the user submit the name, then check it with PHP.

You can check it by placing the name the user has entered to the WHERE clause of your query.

1
  • 2
    Or, rather, have MySQL scan it WHERE username = 'Joe'. Commented Feb 2, 2012 at 21:22

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.