I just want to know how to subtract 1 from the number that appears in $row[posts_remaining]
In other words...
<?php
$con = mysql_connect($db_server_name,$db_username,$db_password);
if (!$con) {
//do something
}
mysql_select_db("" . $db_database_name . "", $con);
$result = mysql_query("SELECT * FROM users
WHERE fb_id='$user_id'");
while($row = mysql_fetch_array($result)) {
$posts_remaining = $row['posts_remaining']
// this is where I want to subtract 1 and then update "posts_remaining" with the new number
}
mysql_close($con);
?>
This will give me my result where row posts_remaining = {THE NUMBER}
But I want to update that returned number by subtracting one from it and then SETting the new number in back where the old number was.
I hope Im not making this confusing. It's hard to explain.
Additionally... should I have the row "posts_remaining" set as something other than TEXT in order to do this.... like Char(50) or something or is it ok to leave it as TEXT?
First you have to modify the type of the field from text to integer Than for update records try this query
You can do it using database query itself: