php - Trying to make a counter everytime I click a button -
so whenever click button counter go , save mysql database. heres have far doesn't echo number gives no errors.
try {   $db = new pdo('mysql:host=localhost;dbname=mydatabse;charset=utf8', 'myusername', 'password'); } catch(exception $e) {     die('error : '.$e->getmessage()); }  if( isset($_post['clicks']) ) {      $sql = "update clicks set clicks=clicks+1";     $result - $db->query($sql); }  $row = $db->query('select * clicks');  while ($data = $row->fetch()) {     echo $data["clicks"]; } i don't know if clicking part works either due nothing ebing echoed...
the sql table is: big int 20 clicks
fix this:
$result - $db->query($sql); to this:
$result = $db->query($sql); 
Comments
Post a Comment