WordPress setup one database with two different website?

It is pretty hard to tell since you didnt give a lot of information, but First, make sure both sites connect to the same database. Then add those lines in the wp-config.php of each sites to make sure your sites are going to get the right value of wp_home and wp_siteurl depending on which server your are connected to :

define('WP_HOME','http://' . $_SERVER['SERVER_NAME']);
define('WP_SITEURL','http://' . $_SERVER['SERVER_NAME']);