Header ("Content-type:image/png");
- $conn = mysql_connect ("localhost", "root", ""); Connecting to a database
- $colname _rs_article = $_get[' id ']; Get parameter ID
mysql_select_db ("CMS", $conn); Execute SQL
- $query _rs_article = sprintf ("select * from articles where article_id =%s", $colname _rs_article);
- $rs _article = mysql_query ($query _rs_article, $conn) or Die (Mysql_error ());
- $row _rs_article = Mysql_fetch_assoc ($rs _article);
- $totalrows _rs_article = mysql_num_rows ($rs _article);
PHP GD Library Create watermark
- $image = Imagecreatetruecolor (700, 1000); Create a canvas
- $BG = Imagecolorallocate ($image, 255, 255, 255); Set the background to white
- Imagefill ($image, 0, 0, $BG);
- $text _color = imagecolorallocate ($image, 0, 0, 0); Set text color to Black
- Imagestring ($image, 5, 0, 0, $row _rs_article[' title '), $text _color); Output article title
- Imagestring ($image, 3, 0, $row _rs_article[' author '), $text _color); Output article author
- Imagestring ($image, 4, 0, $row _rs_article[' content '), $text _color); Output article content
- $logo = imagecreatefrompng (' logo.png '); Get watermark Picture
- $logow = Imagesx ($logo);
- $logoh = Imagesy ($logo);
- Imagecopy ($image, $logo, 0, 0, 0, 0, $logow, $logoh); Merge text picture with watermark picture
- Imagejpeg ($image); Output to Browser
- Imagedestroy ($logo);
- Imagedestroy ($image);
- ?>
Copy Code |