How would I create (for a mySQL database) a PHP function that has two parameters: the first being a column name in the table and the second being a username? The function should return the table's value in that column for the given username.
Essentially, I need something like the below code (which is for a SQLite Database and Java), but in PHP.
public String getInformation(String information, String username) {
SQLiteDatabase db = getReadableDatabase();
Cursor cur = db.rawQuery("SELECT " + information + " FROM registeruser WHERE username=" + "'" + username + "'",null);
String result = "";
if (cur.moveToFirst()) {
int resultColumn = cur.getColumnIndex(information);
result = cur.getString(resultColumn);
}
return result;
}