I'm trying to show the result HTML table based on team name
I'm able to echo right team name but unable to use it into a variable in my 2nd query I'm not able to find out what I'm doing wrong here why the query result is not visible. do I need to change something in my code?
<?php
include_once("connection.php");
$sql = "SELECT TeamName FROM `superuser` WHERE id = '303016'";
$queryRecords2 = mysqli_query($conn, $sql) or die("error to fetch employees data");
while ($row2 = $queryRecords2->fetch_assoc()) {
echo $row2['TeamName']."<br>";
}
if(isset($_POST['search']))
{
$valueToSearch = $row2['TeamName'];
$valueToSearch2 = $_POST['valueToSearch2'];
$valueToSearch3 = $_POST['valueToSearch3'];
$sql = "SELECT * FROM `dailydata` WHERE TeamName = '".$valueToSearch."' and Date BETWEEN '".$valueToSearch2."' AND '".$valueToSearch3."'";
$queryRecords = mysqli_query($conn, $sql) or die("error to fetch employees data");
}
else {
$sql = "SELECT * FROM `dailydata` WHERE TeamName = ''";
$queryRecords = mysqli_query($conn, $sql) or die("error to fetch employees data");
}
?>