<?php
mysql_query(SELECT * FROM 'tabelka' WHERE wartosc='wartość')
mysql_query(INSERT INTO....)
?>