How to use a variable (for wordpress postid) in other queries?

When you use the variable, don’t use the quotes. So it would be like:

echo get_the_permalink( $number );

You can also use:

echo get_permalink( $number );

or:

the_permalink( $number )

get_the_permalink() is an alias for get_permalink().