Let's say I have a piece of code that is getting all records from a particular table. Such as:
mysql_select_db($database_localhost, $localhost);
$query_getTechs = "SELECT * FROM zip_tech ORDER BY tech_name ASC";
$getTechs = mysql_query($query_getTechs, $localhost) or die(mysql_error());
$row_getTechs = mysql_fetch_assoc($getTechs);
$totalRows_getTechs = mysql_num_rows($getTechs);
Is there a way to make this a function where the table name and sort by column are part of the function's arguments? So I could put something such as:
get_records('zip_tech','tech_name');
I end up with a lot of these on some things I'm trying to build as I learn PHP. It seems like having to use blocks of code like that repeatedly makes things more convuluted and less clean looking.