Header ("content-type: image/png ");
- $ Conn = mysql_connect ("localhost", "root", ""); // connect to the database
- $ Colname_rs_article = $ _ get ['id']; // get the 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 );
// Create a watermark for the php gd Library
- $ Image = imagecreatetruecolor (700,100 0); // 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 the text color to black.
- Imagestring ($ image, 5, 0, 0, $ row_rs_article ['title'], $ text_color); // output the article title
- Imagestring ($ image, 3, 0, 20, $ row_rs_article ['author'], $ text_color); // output author
- Imagestring ($ image, 4, 0, 60, $ row_rs_article ['content'], $ text_color); // output the article content
- $ Logo = imagecreatefrompng('logo.png '); // Obtain the watermark image
- $ Logow = imagesx ($ logo );
- $ Logoh = imagesy ($ logo );
- Imagecopy ($ image, $ logo, 0, 0, 0, 0, $ logow, $ logoh); // merge text images and watermark images
- Imagejpeg ($ image); // output to browser
- Imagedestroy ($ logo );
- Imagedestroy ($ image );
- ?>
|