PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Sep 23, 2018 5:51 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Jul 31, 2004 5:29 pm 
Offline
Forum Contributor

Joined: Wed Jul 14, 2004 4:06 am
Posts: 139
To avoid the download of adress data, to be precise the evaluation, the from the database generated adresses should be displayed as a graphic.
For example the company name should be fetched from the database and automatically be converted to a graphic.

1. How do I do that? Are there any GPL scripts out there?
2. Is there any other solution avoiding the evaluation of adresses? GIF graphics will at the end enlarge the output file, which ofcourse is not so nice for the user.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 31, 2004 5:37 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
http://php.net/gd


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 31, 2004 5:59 pm 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada
http://php.net/ming


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 31, 2004 8:47 pm 
Offline
Forum Regular
User avatar

Joined: Sun Oct 06, 2002 1:24 pm
Posts: 823
Location: Toronto, Canada
Holy whoa! You can generate Flash movies with PHP??? Visionmaster, as for your problem, may I present to you, the solution using GD. The following script will pull the data out of a mysql database and output it on a white image in black letters. I will also attempt to explain each line:

Syntax: [ Download ] [ Hide ]
<?php

//I assume you are pulling your information from a database, so you want to perform a query:

$db = mysql_connect ("localhost", "", "");

$result = mysql_query ("SELECT address FROM table WHERE /* condition */", $db);

$information = mysql_fetch_array($result);



//generate a new image, allocate space for it

$newimage = imagecreatetruecolor(100, 33); //10 and 33 is the image size in pixels



//set the background colour to white, and define what "black" means

$background = imagecolorallocate($newimage, 255, 255, 255);

$fill = imagefill($newimage, 0, 0, $background);

$black = imagecolorallocate($newimage, 0, 0, 0);



//write your information in black letters to the image

imagestring($newimage, 5, 10, 10, $information['address'], $black); //5 is font information, 10,10 are the coordinates where the text will be placed



//create, output, and destroy the image

header("Content-type: image/png");

imagepng($newimage);

imagedestroy($newimage);

?>


Assuming you saved this script as image.php, you can access it from a regular html page using
Syntax: [ Download ] [ Hide ]
&amp;lt;img src = "image.php"&amp;gt;


You can even pass variables like you would to any other php script:
Syntax: [ Download ] [ Hide ]
&amp;lt;img src = "image.php?var=value&amp;amp;anothervar=anothervalue"&amp;gt;


Small note, this actually outputs a png, not a gif. You can change this a little so it outputs a jpeg if that's your preference, personally, I prefer png's. This will increase the loading time of the page (obviously!) because not only does the image have to be downloaded by the end user, it also has to be created by the server. However, for what you ask, I don't see any other solution.

Hope this helps you!

~evilmonkey.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group