Arduino to HTML string via Serial

Hi there, I will explain this as simply as possible, as I don't believe it to be a particularly complex question.
Whilst I know that language choice can be a matter of preference, I am unsure about how to go about this particular idea, and can't decide which would be best suited.
Moreover, the only coding experience I have is with C++ (and HTML/CSS).

From the examples listed in the Arduino Tutorials it seems to me that Processing or Java would be most suitable, but see what you think.

I have a set of LDRs connected to an Arduino MEGA that tell me when someone is sitting on them. When someone sits on one, the value of two ints changes:

dayusers++;
allusers++;

I need to read these values FROM the arduino via SERIAL and have them inform a webpage of their values so that they may be displayed to the public. The Arduino will not be connected via an ethernet shield or a wireless shield, (the laptop will be online) and will, I presume, print something like the following:

Serial.print ("<div class=\"numbers\" id=\"day\">");
Serial.print (dayusers);
Serial.println ("</div>");
Serial.print ("<div class=\"numbers\" id=\"alltime\">");
Serial.print (allusers);
Serial.println ("</div>");

But there needs to be something this is communicating to, obviously, rather than just the serial monitor, so I assume the easiest, clumsiest way to do it is to write to an html file, or text file, and I guess a neater way is somehow java based, but apart from that, I'm lost.

I saw things written about client.print but I'm not connected as a server and client per se, so I'm not sure what my next step is.

What language do you think would be most suited to interpreting this data and having it update, live on the internet?

Thank you for your help in advance.

I need to read these values FROM the arduino via SERIAL

Well, you can't. You can make the Arduino write the values to the serial port, and have another application connect to the other end of the serial port and read the data.

The Arduino will not be connected via an ethernet shield or a wireless shield, (the laptop will be online) and will, I presume, print something like the following

Way too complicated. All the Arduino should be printing is something like:

Serial.print ("<");
Serial.print (dayusers);
Serial.println (", ");
Serial.print (allusers);
Serial.println (">");

But there needs to be something this is communicating to, obviously

Obviously.

so I assume the easiest, clumsiest way to do it is to write to an html file, or text file, and I guess a neater way is somehow java based, but apart from that, I'm lost.

The Arduino can't do that directly. The PC application would need to.

I guess a neater way is somehow java based,

What would lead you to guess that?

I saw things written about client.print but I'm not connected as a server and client per se, so I'm not sure what my next step is.

It doesn't involve client.print().

What language do you think would be most suited to interpreting this data and having it update, live on the internet?

The one that you know.

This is really a two step process. One application reads the data from the serial port, and stores it in some place (a MySQL database?) that the web browser/script can access it. I'd use php to create the script that the web browser accesses, and C# to write the program that reads the serial port and writes to the database.

Your skill set might be completely different.

As I have no experience with these languages, but not a lot of other particularly useful experience, either, I decided now was a good time to learn and have spent today swotting up at the library. I've come up with some of the elements I think I need, but am still a long way off. If you could provide any pointers, that would be fantastic.

I'm going to start by outlining that (I think) I only need a very simple table in SQL to store the data:

UPTIME   NUMBERZ
DAYHK     123456
ALLHK     234567
DAYVN     123456
ALLVN     234567

Written thus (excepting data for 'numberz' column, as this will be UPDATEd by the C# program):

CREATE DATABASE USERS;
USE DATABASE USERS;
CREATE TABLE USER_NUMBERS (
UPTIME CHAR(5),
NUMBERZ NUMERIC NOT NULL
);
INSERT INTO USER_NUMBERS VALUES (
DAYHK, 0);
INSERT INTO USER_NUMBERS VALUES (
ALLHK, 0);
INSERT INTO USER_NUMBERS VALUES (
DAYVN, 0);
INSERT INTO USER_NUMBERS VALUES (
ALLVN, 0);

With the table set up and ready to be both updated by the C# program, and to have its numbers pulled by the PHP script, I decided next to write the PHP:

<?php
$con=mysql_connect(servername,username,password);
if (!$con)
{
die ('could not connect: ' . mysql_error());
}
mysql_select_db("USERS", $con);

$duhk=mysql_query("SELECT NUMBERZ
FROM USER_NUMBERS
WHERE UPTIME = DAYHK");

$auhk=mysql_query("SELECT NUMBERZ
FROM USER_NUMBERS
WHERE UPTIME = ALLHK");

$duvn=mysql_query("SELECT NUMBERZ
FROM USER_NUMBERS
WHERE UPTIME = DAYVN");

$auvn=mysql_query("SELECT NUMBERZ
FROM USER_NUMBERS
WHERE UPTIME = ALLVN");

while ($au >= 0){
echo "<div class=\"numbers\" id=\"dayhk\"> $duhk </div>";
echo "<div class=\"numbers\" id=\"allhk\"> $auhk </div>";
echo "<div class=\"numbers\" id=\"dayvn\"> $duvn </div>";
echo "<div class=\"numbers\" id=\"allvn\"> $auvn </div>";
}
?>

So now I can put that on my HTML page, style that information however I wish in CSS, and it will update, as long as it is being updated by the C# program. I hope.

Okay, now the tricky part, the C#.

I have worked out so far that I need this information somehow involved, but am not too sure on the syntax, or, well, anything:

using System.IO.Ports;
using System.Data.SqlClient;
SqlConnection myConnection = new SqlConnection("user id=username;" + 
                                       "password=password;server=serverurl;" + 
                                       "Trusted_Connection=yes;" + 
                                       "database=database; " + 
                                       "connection timeout=30");
try
{
    myConnection.Open();
}
catch(Exception e)
{
    Console.WriteLine(e.ToString());
}


SerialPort sp = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);

private Program()
        {
            sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
            sp.Open();
            Console.Read();
        }

private void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            Console.WriteLine(sp.ReadExisting());
        }

 SqlCommand myCommand = new SqlCommand("UPDATE USER_NUMBERS
SET NUMBERZ= dayusershk //variable??
WHERE UPTIME = DAYHK");

SqlCommand myCommand = new SqlCommand("UPDATE USER_NUMBERS
SET NUMBERZ= allusershk //variable??
WHERE UPTIME = ALLHK");

SqlCommand myCommand = new SqlCommand("UPDATE USER_NUMBERS
SET NUMBERZ= dayusersvn //variable??
WHERE UPTIME = DAYVN");

SqlCommand myCommand = new SqlCommand("UPDATE USER_NUMBERS
SET NUMBERZ= allusersvn //variable??
WHERE UPTIME = ALLVN");

Nghhhhh. I understand that this is still a long way off; for a start I don't even have a Main. Still very much getting to grips with this, but I think the other pieces are coming along. If you can give any advice, it would be much appreciated.

Thank you in advance.

Okay, after following a tutorial, I can't even make the console print the serial input. Here's the code I'm using. Am I wrong in thinking it ought to work?
When I Start the Program in Visual Studio, a cmd window pops up, and disappears instantly. When I start it without debugging, it pops up, says 'Press any key to continue' and when i do, it closes.

using System.IO.Ports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Read_Serial
{
    class Program
    {
        SerialPort sp = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
        static void Main(string[] args)

        {
        }
        private Program()
        {
            //Set the datareceived event handler
            sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
            //Open the serial port
            sp.Open();
            //Read from the console, to stop it from closing.
            Console.Read();
        }
        private void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            //Write the serial port data to the console.
            Console.WriteLine(sp.ReadExisting());
        }
    }
}

Since you are only querying whether or not someone is sitting currently, I would have your script update an xml file that your web server reads. No point in setting up a database.

<?xml version="1.0"?>
<root>
<day count="12">
<total count="34">
</root>

I cannot help you on the c#.

Oh my god, XML is beautiful.