brynmyrddinemrys Posted July 25, 2009 Share Posted July 25, 2009 Hey everyone! I am a bit new to php and what I'm trying to do has left me very puzzled. I am designing a wordpress website and, for each blog post, I would like to have its time stamp rotated 90 degrees along the left side of the post. So the text would read vertically, not horizontally. I have heard that his "rotation" feature might be available in future CSS standards, and, while I definitely look forward to this update, I am also looking for ways to make it work without CSS. I have recently read that PHP can accomplish this task very nicely by dynamically embedding text into an image, which can then be sported on any html website. I found this great tutorial at The Gurus Network that discusses the process briefly - but for my purpose, it leaves a few questions unanswered. I am now able to produce a rotated image from an arbitrary string of text ("TEST"). I have created a file called "new-date.php" that does this: <?php // Set the static variables (discussed in step 3) $font_file = $_SERVER['DOCUMENT_ROOT']."/verdana.ttf"; $font_size = 14; $x_start = 25; $y_start = 150; $angle = 90; $max_width = 300; // Retrieve random fortune from text file (discussed in step 2) $text = "TEST"; // Create the image resource and assign colors to variables (discussed in steps 1 and 5) header("Content-type: image/png"); $im = imagecreatefrompng("blank.png"); $red = imagecolorallocate($im, 255, 255, 255); // Write the text to the image (discussed in step 4) imagettftext($im, $font_size, $angle, $x_start, $y_start, $red, $font_file, $text); // Create and then destroy the image (discussed in steps 5 and 6) imagepng($im); imagedestroy($im); ?> But how would I go about linking this php code to my mysql database, so that it reads the date for each post and creates a different image for each post? Is this even possible? Something like: $text = the_date(); OR $text = mysql2date(); Though I know those examples don't work because, currently, my "new-date.php" does not seem to recognize any external variables or functions. Is there a way to access these functions? Or maybe I could pass some variables to "new-date.php" each time it loads on the page? Any help/ideas would be greatly appreciated. Thanks! Quote Link to comment Share on other sites More sharing options...
brynmyrddinemrys Posted July 25, 2009 Author Share Posted July 25, 2009 Nevermind... I figured it out. The trick is to pass a date variable through the image "src" tag. If anyone wants a more detailed explanation about how to do this, I'd be happy to help. Otherwise, thanks anyways. Quote Link to comment Share on other sites More sharing options...
.josh Posted July 26, 2009 Share Posted July 26, 2009 I'm so awesome I solve problems without even posting. Quote Link to comment Share on other sites More sharing options...
brynmyrddinemrys Posted July 26, 2009 Author Share Posted July 26, 2009 Impressive, CV! Next, you should figure out how to solve problems before they've been posted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.