scott532 Posted May 14, 2006 Share Posted May 14, 2006 Hey people,I am trying to figure out what this means:[code]$sql = sprintf("SELECT COUNT(*) AS test FROM %s WHERE email = '%s' OR login = '%s'", $this->table_name, $this->user_email, $this->user);[/code]I have searched through my PHP book (by Eric Rosebrock) and searched the MySQL docs, but I cannot figure out, specifically, what the following are:[ol type=\'1\'][*]What is [code]AS Test[/code] referring to?[*]What is the purpose of [code]%s[/code]?[/ol]If someone could explain these two questions I will be greatful.Thanks- for putting up with a [i]newb[/i],Scott G. Quote Link to comment Share on other sites More sharing options...
Carth Posted May 14, 2006 Share Posted May 14, 2006 [a href=\"http://www.php.net/sprintf\" target=\"_blank\"]sprintf()[/a] replaces %s with the variables supplied in the second parameter, in the order they are provided. So "FROM %s" will turn into "FROM $this->table_name".The "COUNT(*) AS test" is a way of getting the number of rows returned, and it will be returned in a column called "Test", there should be something in the manual under SELECT about it Quote Link to comment Share on other sites More sharing options...
scott532 Posted May 14, 2006 Author Share Posted May 14, 2006 Thanks Carth, i get it now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.