Jump to content

Updating int avalue


user4fun

Recommended Posts

$q2 = mysql_query("SELECT `Site` FROM `checking` WHERE `Site` = '" . strtolower($_POST['site']) ."' LIMIT 1"); 	IF (mysql_num_rows($q2) == 1) :  echo "already in system";//help heredie();ENDIF;

help here.I want to add an update section that would pick the column Contacted in table checking where column Site = strtolower($_POST['site']);takes the INT value in the Contacted column and make it ++ ( or i guesss +1 wouldbethe same thing)

Link to comment
Share on other sites

$q2 = mysql_query("SELECT `Site` FROM `checking` WHERE `Site` = '" . strtolower($_POST['site']) ."' LIMIT 1"); 	IF (mysql_num_rows($q2) == 1) :  echo "already in system";//help heredie();ENDIF;

help here.I want to add an update section that would pick the column Contacted in table checking where column Site = strtolower($_POST['site']);takes the INT value in the Contacted column and make it ++ ( or i guesss +1 wouldbethe same thing)

I don't know exactly what you're trying to do, but it looks like you're trying to check that your record exists before you update it. You don't need to do that, its a superfluous step. Also, you don't need to use the strtolower function, because MySQL is case-insensitive by default.The entire block of code in your opening post can be replaced by executing this SQL statement:
UPDATE `Checking` set `Site` = `Site` + 1 WHERE `Site` = $_Post['site']

If you only want your Site column to equal 0 or 1, then you can alter your query very slightly with MySQL's built-in Sign() function:

UPDATE `Checking` set `Site` = Sign(`Site` + 1) WHERE `Site` = $_Post['site']

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...