title: wordpress php add value to database
body: <p>I'm very new to the idea of adding values to a database, so would like some advise on whether this is possible and how I would do it.</p>
  
  <p>I have a code that counts the lines of code written in a project, the code has to be in the folder that it is counting the lines of code from however I want to display this number on my site elsewhere. My site is a wordpress one, so i thought of sending this number to the database and calling on it in a template file elsewhere.</p>
  
  <p>Is there a way to send this number to my database and have it keep up to date in real-time so that I can call it from other places in my site?</p>
  
  <p>My LOC script can be seen running here:
  <a href="http://www.skizzar.com/wp-content/loc.php" rel="nofollow">http://www.skizzar.com/wp-content/loc.php</a></p>
  
  <p>and the number is displayed using the command:</p>
  
  <pre><code>$folder -&gt; count_lines()
  </code></pre>
  
  <p><strong>update</strong></p>
  
  <p>I've added the following code to my loc.php</p>
  
  <pre><code>$num_of_lines = $folder -&gt; count_lines();
  add_option('line_count', $num_of_lines);
  </code></pre>
  
  <p>And called it in my theme files using</p>
  
  <pre><code>echo get_option('line_count', '0');
  </code></pre>
  
  <p>So far this just returns 0 as the value and causes a fatal error on loc.php "call to undefined function..."</p>
  
  <p><strong>Second update</strong></p>
  
  <p>Got the code to work by adding </p>
  
  <pre><code>require_once('wp-config.php');
  </code></pre>
  
  <p>To the top of my code, the issue now is that it doesn't update in real time - is there a way to do this?</p>