img src

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kesef
Forum Newbie
Posts: 3
Joined: Sat Aug 05, 2006 12:30 pm

img src

Post by kesef »

Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I use the folowing!
[syntax="html"]
<img src="button.php?button=button_down&text=Home&color=red" width="120" height="15" alt="Home" border="0" />
But the text on the button is: button_down
and it should be: Home


Weirdan | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

we would need to see the contents of button.php to help you figure out why that's happening.
kesef
Forum Newbie
Posts: 3
Joined: Sat Aug 05, 2006 12:30 pm

content of button.php

Post by kesef »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php
// GD's built-in fonts are numbered from 1 - 5
$font = 3;
//image size
$image_height = 15;
$image_width = 120;
// Create the image
$image = imagecreatefrompng("button.png");

// Create the colors to use in the image
// blue text
$text_color = imageColorAllocate($image, 0, 0, 255);
// black border
$rect_color = imageColorAllocate($image, 0, 0, 0);
// Figure out where to draw the text
// (Centered horizontally and vertically
$x = ($image_width - (imageFontWidth($font) * strlen($_GET['button']))) / 2;
$y = ($image_height - imageFontHeight($font)) / 2;
// Draw the text
imageString($image, $font, $x, $y, $_GET['button'], $text_color);
// Draw a black border
imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
// Send the image to the browser
header('Content-Type: image/png');
imagePNG($image);
imageDestroy($image);
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by kesef on Sat Aug 05, 2006 1:12 pm, edited 1 time in total.
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

it's best that you use the [syntax=php]content[/syntax] tags.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Why do you think it should be "Home" rather than "button_down"? That script clearly draws the content of the $_GET['button'] variable.
kesef
Forum Newbie
Posts: 3
Joined: Sat Aug 05, 2006 12:30 pm

Post by kesef »

onion2k wrote:Why do you think it should be "Home" rather than "button_down"? That script clearly draws the content of the $_GET['button'] variable.
I don't think it should be Home :(
I would like that it is home :D
and now it is:
button_down
button_up
button_over
instead of the color that has to change
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

You seriously can't work this out?
Try:

Code: Select all

imageString($image, $font, $x, $y, $_GET['text'], $text_color);
instead of:

Code: Select all

imageString($image, $font, $x, $y, $_GET['button'], $text_color);
Post Reply