For example: Stackoverflow's page
I push F12 in Crome web-browser and in console put next:
var item = document.querySelectorAll('.question-summary');
var outputValue = item.length;
outputValue;
The output I get is 15
Question is can I send this info (the output value) to my myfile.php file (for example get sing in one of my divs There are 15 questions on that particular stackoverflow's page
via <? echo 'There are ' . outputValue . ' questions on that particular stackoverflow's page'; ?>
), so in future I'll be able to put this information to MySQL database (but for now I just need to print out outputValue
on myfile.php )?
Yes, using a GET request, you could pass the length as a query string parameter -
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET", "server.php?question-summaries="+item.length);
xmlhttp.send();
server.php
if (is_numeric($_GET['question-summaries'])) {
// Insert into database
}