php - adding 5 to the $i after inserting the $i -


<?php  mysql_connect("localhost", "root", "");  $db=mysql_select_db("test");  $i=1;  $r=" insert test1 (score) values ('$i') "  ;  $t=mysql_query($r);  if($t){    $i=$i+5;   echo  "done";   } else {     echo "not done";   } ?> 

i writing simple program new in php world not able find logic . . have defined $i value ie 1 , want insert value database

when user again refreshes page , $i value should add 5 , insert value . please can tel me how b done ??

this code should trick think:

<?php     session_start();     mysql_connect("localhost", "root", "");     $db=mysql_select_db("test");     if(isset($_session['counter']))     {         $i=$_session['counter'];     }     else     {         $i=1;     }     $r=(" insert test1 (score) values ('$i') " ) ;     $t=mysql_query($r);     if($t)     {      $i=$i+5;     echo  "done"; }     else     { echo "not done"; }     $_session['counter']=$i; ?> 

basically, can store data inside session variable, maintained on server , maintains, session, client/user. can refer in following pages.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -