First, run a query. For this example, we'll assume the table only holds one thing: id. It'll be easy to add other parts, I'm just keeping it simple.
$query = "SELECT * FROM table WHERE id=1";
$result = mysql_query($query);
Now, we check if there were results.
if (mysql_num_rows($result) >= 1) {} //exists
else {} //doesn't exist.
I think you can probably take it from here. If not, just ask and I'll help.