Jump to content

[SOLVED] A question about accessing functions in php


Recommended Posts

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!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.