I'm looking for a way to run this script through a table in my MySQL database.
- Firstly, how do I define the table in which to loop this script?
- How do I add the result of
get_httpcodeinto another field in the record, 'imgstatus'?
Are there any better ways of approaching this?
<?php
// Create connection
$con=mysqli_connect("xxxx","xxxx","xxxx","xxxx");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
function get_httpcode($url) {
$headers = get_headers($url, 0);
// Return http status code
return substr($headers[0], 9, 3);
}
while($data = mysql_fetch_assoc($sql)):
$result = get_httpcode('http://'.$data['img']);
echo $data['img'].' = '.$result.'<br/>';
endwhile;
?>