我有一个mysql数据库,我想确保当它是某人的生日时,在横幅上出现了写作。 我的横幅脚本:
<?PHP
header('Content-Type: image/jpeg');
$host_db='127.0.0.1';
$Login_db='root';
$pwd_db='**********';
$bdd_name='regTS3';
$oggi= date("d/m/Y");
$conn=mysql_connect($host_db,$Login_db,$pwd_db);
mysql_select_db($bdd_name,$conn);
$result = mysql_query('SELECT * FROM `regTS3` WHERE `Anni` = '.$oggi.';');
$Data= Array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$i=0;
$Data[$i] = $row['Nome'];
$i=$i+1;
}
$img = imagecreatefromjpeg("banner.jpg");
$color = ImageColorAllocate($img, 83, 196, 225);
$color2 = ImageColorAllocate($img, 83, 196, 225);
$font= "./pitt.ttf";
$font2="./verdana.ttf";
$text = date("H:i");
$text2 = "Test";
imagettftext($img, 28, 0, 560, 70, $color, $font, $text);
imagettftext($img, 30, 0, -150, 190, $color2, $font2, $Data[0]);
imagejpeg($img);
imagedestroy($img);
?>
答案 0 :(得分:0)
你可以这样做更简单:
$result = mysql_query('SELECT Nome FROM `regTS3` WHERE DATE_FORMAT(Anni,\'%d%m\') = DATE_FORMAT(NOW(),\'%d%m\')');
$Data= Array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$Data[] = $row['Nome'];
}
$img = imagecreatefromjpeg("banner.jpg");
$color = ImageColorAllocate($img, 83, 196, 225);
$color2 = ImageColorAllocate($img, 83, 196, 225);
$font= "./pitt.ttf";
$font2="./verdana.ttf";
$text = date("H:i");
$text2 = "Test";
imagettftext($img, 28, 0, 560, 70, $color, $font, $text);
if (count($Data) > 0) {
$string = implode(" ", $Data);
imagettftext($img, 30, 0, -150, 190, $color2, $font2, $string);
}