I am developing and developed couple of websites in php succeccfully but many times I have seen a query a default function of php which i see in many tutorials it has been used but I am confused about it.
The function is mysqli_inser_id() I mean can anyone explain me what is the pupose and where we have to use it and where and when we need this function?
Yes by viewing it generates ID which is created by the query but if we do not use this function the Auto Increment took place on every query though when ever a new record is added the id also increments is it true right this happens
It is used to give you the autoinc field value of the last record manipulated (update or insert). It can be useful if you want to insert data into more than one table. For example if you had this:
users: id | email | username | password
telephones: user_id | telno
If you had a form for adding a new user which had multiple form fields (unlimited) for telephones, you wouldn't store them all in the users table as it may violate 1NF (normalization), if, for example, you thought of storing telephone numbers as a comma separated string. So first you add data to the users table as usual, then, because you need the user_id you just created for adding telephone numbers to the telephones table, you need to call mysqli_insert_id() or the OOP equivalent.