Keeping a counter
<p>*<em>Here is what I am trying to acheive: *</em>
Basically I have a form where people can submit events to our database. In the CMS I have a page which displays a record of the number of events.</p>

<p>*<em>Here is what I have: *</em>
After the button is clicked, this script is called:</p>

<pre><code>if($subject_type == 'Event') {

  $query = "SELECT town, update_id, event_validex ";
  $query .= "FROM dev_town ";
  $query .= "LEFT JOIN updates ON dev_town.town_id = updates.town ";
  $query .= " WHERE sitename  = '".SITENAME."'";
  $query .= " AND month = " .date('m')." AND year =" .date('Y');

  $querys = $this-&gt;tep_db_query($query);
  $rows = $this-&gt;tep_db_fetch_array($querys);

  extract($rows); //extract rows, so you don't need to use array 

  $eventid = $event_validex + 1;

  $sql_data_array = array('event_validex' =&gt; $eventid);


  $submit_to_database = $this-&gt;tep_db_perform('updates', $sql_data_array, 'update', "town='".$town."'");
</code></pre>

<p>This works fine, however I cant seem to solve the next bit</p>

<p><strong>This is the Problem</strong>
As you can see, it checks the database for the current month and adds it, this is providing that the sitename and that month are there, not a site and another month. </p>

<p>How would I get it to add the row in IF the sitename and month are not there?</p>

<p>I have been manually adding the months in now so that it works, and I am sure you can agree that's a ball ache. </p>

<p>Cheers peeps</p>
