get id custom tables on current page

I am not sure that I understand the question but if $bab->id is the ID in the $wpdb->post table then get_permalink($bab->id); will give you the permalink for the page.

If you are trying to get the ID of the page after you click those links, try:

echo $post->ID;
// or...
$pobj = get_queried_object();
echo $pobj->ID;

Again, it is very hard to tell what you are asking so I am making a series of guesses.