I have a web page that displays a list of names that change throughout the day. I also have a database that contains a list of all of these names.
I need to somehow run a search on the names that are displayed on the web page at any specific time, then match these against the names that are contained in the db. This is sort of a reverse lookup.
The names that are unable to be found on the web page need to be displayed.
How do I go about doing this?
I am attempting to try parsing the names contained in the db rows to an array and the names on the web page to another array then comparing the two arrays.
I have managed to parse them correctly but there is an issue when I try comparing them.
Please point me in the right direction :)
<?php
$a = file_get_contents("https://testpage.com/pbx_info2.php");
#find all the names that are contained within '[' and ']'
preg_match_all('^\[(.*?)\]^', $a, $matches);
#output all the names into an array
$output = $matches[0];
#remove the '[' and ']' characters and print the contents of the array.
foreach($output as $u) {
$u = str_replace ('[', '', $u);
$u = str_replace (']', '', $u);
print $u;
echo "<br>";
}
$con=mysqli_connect("localhost","test_user","test_pass","test_teaams");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "<br>Connected!<br>";
}
$sql="SELECT * FROM test_table";
if ($result=mysqli_query($con,$sql))
{
while ($row=mysqli_fetch_row($result))
{
printf (" ".$row[0],$row[1]);
}
// Free result set
$people[0] = mysqli_free_result($result);
$peep = $people[0];
}
$missing = array_intersect($output, $people);
printf ($missing);
mysqli_close($con);
?>