I just need to create a simple php page that can query one table(ad_data), and compare two columns against rows in another table(time_clock_data), and return the value of the column 'Login Name' in time_clock_data. However, when i run the page it pulls everything from ad_data fine, but the time_clock_data 'Login Name' returns null.
Here is my code:
<?php
mysql_connect("localhost", "root", "") or die (mysql_error ());
$conn = new mysqli("localhost", "root", "", "uh_time_clock");
mysql_select_db("uh_time_clock") or die(mysql_error());
function queryAd(){
$adQuery = mysql_query("SELECT * FROM ad_data ORDER BY 'First Name' DESC");
while($ad = mysql_fetch_array($adQuery)) {
$adFirstName = $ad['First Name'];
$adLastName = $ad['Last Name'];
$adLoginName = $ad['Login Name'];
echo "<li>" . $adLoginName . "</li>";
mysql_select_db("uh_time_clock") or die(mysql_error());
$tcQuery = "SELECT * FROM time_clock_data WHERE 'First Name' = '$adFirstName' and 'Last Name' = '$adLastName'";
$tc = mysql_fetch_assoc( mysql_query($tcQuery) );
$tcLoginName = $tc['Login Name'];
echo "<li>" . $tcLoginName . "</li>";
}
}
queryAd();
mysql_close();
?>