nodeMCU Updating Label in web server

hi guys can someone help me im new to programing and im trying to make an html that have a label where the text is updating on what the LDR is getting connected to a nodeMCU. is it possible to send data from the LDR and change the text of a html label in my phone? is there a simple code on how to do this?

It is possible to do what you want. Have you got a Webserver running on the nodeMCU serving fixed test to clients ? If so, then please post the code here. If not then please look at the examples in the IDE

i got this working in my phone it shows the webpage.

#include <ESP8266WebServer.h>
#define LDR 2

const char* ssid = "neneboots";;
const char* password = "87654321";
String notice;


ESP8266WebServer server(80);

char webpage[] = R"=(
<!DOCTYPE html>
<html>
<body>
<h3>LDR VALUE </h3>
<div><label>0.00 units</label></div>
</body>
</html>
)=";



void setup() {

  float LDRVALUE;

  //Wifi as access point__________________
  Serial.begin(115200);
  Serial.print("CONNECTING TO ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(400);
    Serial.print("-");
  }
  Serial.println("");
  Serial.println("WIFI CONNECTED!");
  server.begin();
  Serial.println("SERVER STARTS AT : ");
  Serial.println(WiFi.localIP());
  //Server________________________________
  server.begin();
  server.on("/postForm", handlePostForm);   
}


void loop() {
  LDRVALUE = analogRead(LDR);
  server.handleClient();
  delay(10);
}

yes you can dynamically 'poll' the LDR value

all you have to do is set a timer on JS ( with setInterval() ) that repeatedly sends request to the ESP, at say

every 500 milli_secs

the response from the ESP carries the LDR value you want

see this

i got this working in my phone it shows the webpage.

Then at its simplest all you need to do is to change your webpage string at intervals and put the value of LDRVALUE in the appropriate place in the HTML code and the Webserver will serve the updated page including the value of LDRVALUE

The post convenient way to update the webpage string is probably to use the sprintf() function

sorry but do you have an example of this that i can watch? cause to be honest i still dont understand how i can do this.

sprintf() is a standard C function
Here is an example of it used to change a char array named webpage

char webpage[200];
float ldrValue;

char ldrChars[10];

void setup()
{
  Serial.begin(115200);
  while (!Serial);
  ldrValue = 123.45;
  makePage();
  Serial.println(webpage);
  ldrValue = 1023.99;
  makePage();
  Serial.println(webpage);
}

void loop()
{
}

void makePage()
{
  dtostrf(ldrValue, 5, 2, ldrChars);  //convert float to string for sprintf()
  sprintf(webpage, "\
  <!DOCTYPE html>\
  <html>\
  <body>\
  <h3>LDR VALUE </h3>\
  <div><label>%s</label> </div>\
  </body>\
  </html> ", ldrChars);
}