📜 ⬆️ ⬇️

An interesting passage of the registration script

I looked through the sources of one project, a foreign portal with the possibility of publishing audio-video, etc., is not important. And this is how registration of users is implemented there, or rather, getting the user id when registering it.
CodBred?
function getNewId ($ tableName, $ idFieldName) {
$ query = "SELECT MAX ($ idFieldName) FROM $ tableName";
$ result = mysql_query ($ query) or die ("Error in getting new id:" .mysql_error ());
if ($ result) {
$ record = mysql_fetch_row ($ result);
if ($ record> = 0) {
return ($ record [0] +1);
}
}
return 0;
}

PS Programmer Hindu

')

Source: https://habr.com/ru/post/28527/


All Articles