Running two sensors at two different timings

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <ESP8266HTTPClient.h>
#include"DHT.h"
#define DHTPIN 04 // Data Pin of DHT 11 , for NodeMCU D5 GPIO no. is 14
#define DHTTYPE DHT11 // DHT 11
#include <BlynkSimpleEsp8266.h>
#include <FirebaseArduino.h>
DHT dht(DHTPIN, DHTTYPE);
int inputpin=16;

char ssid[] = "";
char pass[] = "
";
char auth[] = "***";

WiFiServer server(80);
void setup() {
Serial.begin(115200);

pinMode(D7, OUTPUT);
pinMode(inputpin,INPUT);
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
digitalWrite(D7,LOW);
Serial.println(WiFi.localIP());
Blynk.begin(auth, ssid, pass);
server.begin();
Firebase.begin(FIREBASE_HOST);

}
int count=0;
int val;
void loop() {

float h = dht.readHumidity();
float t = dht.readTemperature();
val=analogRead(D0);
if(val<250)
{
digitalWrite(D7,HIGH);
count++;
Serial.println(count);
Firebase.setFloat("Count",count);
HTTPClient http;
String url = "http://192.168.43.113/add.php?people="+String(count)+"&temp="+String(t)+"&humid="+String(h);
Serial.println(url);
http.begin(url);

//GET method
int httpCode = http.GET();
if(httpCode > 0)
{
Serial.printf("[HTTP] GET...code: %d\n", httpCode);
if(httpCode == HTTP_CODE_OK)
{
String payload = http.getString();
Serial.println(payload);
}
}
else
{
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}

else
{
digitalWrite(D7,LOW);
}

Firebase.setFloat ("Temp",t);
Firebase.setFloat ("Humidity",h);
HTTPClient http;
{

String url = "http://192.168.43.113/add.php?people="+String(count)+"&temp="+String(t)+"&humid="+String(h);
Serial.println(url);
http.begin(url);
}

//GET method
int httpCode = http.GET();
if(httpCode > 0)
{
Serial.printf("[HTTP] GET...code: %d\n", httpCode);
if(httpCode == HTTP_CODE_OK)
{
String payload = http.getString();
Serial.println(payload);
}
}
else
{
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();

Blynk.run();
}

This is my code. Ignore firebase and blynk things. Here what i am doing is receiving ir sensor data to count the number of people in the room and Dht 11 sensor to get temperature and humidity of the room and store them in the database. I want to enter data immediately into my database when ir sensor detects something and after a 5 min delay i want to store temp,humidity and count of ir sensor used in database. Whenever i use delay function it affects both the sensors and until i use ir sensor for 5 min it doesnt sends data to database. Please help me with it. Thanx. First time working on arduino.

Please edit your post to add code tags. See the "How to use this forum" post.

Use millis() function

Basically you store previous millis and counting current
if the current miliseconds are 5min from previous milis get reading from sensor
Otherwise ignore it and move on