Page is a not externally linkable
Jeremy_H - 4:11 pm on Jun 1, 2006 (gmt 0)
I'm trying to create a MySQL command where it will look at the value alpha of table A to see if the ip address has already been written. If it has not been written I would like to create a new row with that ip and values alpha and beta. If it has already been written I would like to increase value alpha by one and perform the calculation alpha/beta and set gamma to equal that. I know how to read and write statements, but I have no clue how to conditional conditional statement ("if ip already exists") or perform calculations inside the table. Is there an efficient way in MySQL to do this? Thanks What I have below is a simple write command to log the ip address. It does not check to see if it already exists, and currently creates duplicate records. $link=mysql_connect("site","db","pass");
Hello,
mysql_select_db("db");
mysql_query("INSERT INTO a (ip, alpha, beta, gamma) VALUES ('$REMOTE_ADDR', 'B', 'C', 'D')");
mysql_close($link);