I'm making a simple website the counts up every time someone clicks on the link, I'm new to PHP and MySQL, but I have the basics down. So, I'm having a problem with making a 'goal counter' So lets say I have ht goal set to 700 views. And the page is at 500 views. When the views reach 700, I want the goal to raise 200. So it would be 900, I want this to happen every time the views reach the goal. This is how I tried to do it:
$goalQuery = mysql_query("SELECT * FROM goal");
$goalRow = mysql_fetch_assoc($goalQuery);
if($viewNewCounts == $goal) {
$goalCounts = $goalRow['counts'];
$goalNewCounts = $goalCounts + 200;
$goalUpdate = mysql_query("UPDATE `Recoreder` . `goal` SET `counts` $goalNewCounts");
}
My DB (named 'Recorder') is setup where I have 2 tables: "goal" and "views" each table has a row named "counts"
Here is a visual of what my Database looks like:
|---counts
|---views|
---Recorder| [Tables] [Rows]
|---goal |
|---counts
My counter code looks like this
NOTE: IT WORKS FINE, I'M NOT HAVING TROUBLE WITH MY COUNTER, I'M HAVING TROUBLE WITH MY GOAL
$viewQuery = mysql_query("SELECT * FROM views");
while($viewRow = mysql_fetch_assoc($viewQuery))
{
$viewCounts = $viewRow['counts'];
$viewNewCounts = $viewCounts + 1;
$viewUpdate = mysql_query("UPDATE `Recorder` . `views` SET `counts` = $viewNewCounts");
}