I'm not sure this is your issue (as you have posted a lot of irrelevant code and it's hard to navigate), but this line certainly has a problem:
$total_pages = $total_pages[num];
It looks like you forgot to put quotes around your array element. PHP will treat it as a constant but I'm going to assume you don't have a constant called num. If you had error reporting PHP would have let you know that.
Also the reason the IDs aren't showing up is simply because you're not selecting them:
$query1 = "SELECT generalname, Scientificname, quantity, reorder FROM $tableName LIMIT $start, $limit";
Looks like you're selecting everything but the IDs.