Here's your answer - it's an explanation in more detail of how to get data from javascript to your database using a post or get to an endpoint that you have created which will write the value of localStorage into your database.
The key point is that you need to use a client-side call to make a server write, and this is typically done using the methods described in the below answer. If not, it should help you search more effectively by finding different methods related to this one, that might suit you.
How to pass data from Javascript to PHP and vice versa?
This code might be helpful to explain the idea:
function result() {
var resultText = "your mark is " + (localStorage.getItem("count") || 0) + " from 9";
document.write(resultText);
// set the full text into the hidden field value, or just do .val(localStorage.getItem("count")) if you only want the count.
$("#hdnFieldName").val(resultText);
}
<input type="hidden" id="hdnFieldName" name="hdnFieldName" value="" />
<input type="submit" text="Submit button" onclick="result();" />