First off, here's the function:
##### Begin function get_cat($function_id)
// Selects all categories from database classified by ID
if($function_id != '')
$select_cat = "SELECT * FROM categories WHERE ID=$function_id";
$selected_cat= mysql_query($select_cat) or die ("Couldn't select categories");
$select_cats = "SELECT * FROM categories";
$selected_cats= mysql_query($select_cats) or die ("Couldn't select categories");
$total_cats = mysql_num_rows($selected_cats);
// End function get_cat
As you can see I made it so if there's an ID specified, call it and save row in $selected_cat.
If there is no ID specifed, get them all and put in an array $selected_cats.
Right now I have to call it with:
get_cat($CATID) (To select specific)
get_cat('') (To select all)
Anyone know a better way to clean up my code?
Meh, I also feel so behind because everyone is using a DB class and I've been trying to read up on it but just can't get it down so I have to use old fashioned settings... What's the advantage?
AIM: WrldsGreatestOne (If you can help/explain how to optimize my database functions, please help!)