Jump to content


Photo

Dynamic Image Help


  • Please log in to reply
6 replies to this topic

#1 Tatara

Tatara
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 17 August 2006 - 03:08 PM

I want to make it where the http get var from the file name so i can call it form user.png

code already worked out:

<?php
$con = mysql_connect("host","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
	
if(!mysql_select_db("db", $con)) {
die('Could not connect: ' . mysql_error());
}

//used to find which user to query for in the database
$user = mysql_real_escape_string(trim($HTTP_GET_VARS['user']));

// Query
$sql = "SELECT item,have,need FROM row WHERE user = '$user'";

// Run Query
$result = mysql_query($sql) or die("Error retrieving user info: ".mysql_error());

// Grab the user results
while( $row = mysql_fetch_array($result) ){
   $item = $row['item'];
   $have = $row['have'];
   $need = $row['need'];
}

$height = 25;
$width = 200;
$fontsize = 6;
$frac = $have/$need;
$pct = 100 * $frac;

$img = imagecreate($width,$height);
$red = imagecolorallocate($img,255,0,0);
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
$bg = imageCreateFromPNG ('bg.png');
$bar =imageCreateFromPNG ('fill.png');
imageSetTile ($img, $bg);
imageFilledRectangle ($img, 0, 0, 116, 40, IMG_COLOR_TILED);
imageSetTile ($img, $bar);
ImageFilledRectangle($img, 7, 22, (114 * $frac), 34, IMG_COLOR_TILED);

$font = '04B_09__.ttf';
$text1 = "Questing For";
$text2 = $item;
$text3 = $have . "/" . $need;
$textwidth1 = floor(imagefontwidth($font) * strlen($text1));
$textleft1 = (($width - $textwidth1) / 2) + 12;
$textwidth2 = floor(imagefontwidth($font) * strlen($text2));
$textleft2 = (($width - $textwidth2) / 2) + 12;
imagettftext($img, $fontsize, 0, $textleft1, 8, $white, $font, $text1);
imagettftext($img, $fontsize, 0, $textleft2, 19, $white, $font, $text2);
imagettftext($img, 6, 0, 46, 32, $black, $font, $text3);

header('content-type: image/png');
imagepng($img);
    
?>


#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 17 August 2006 - 04:20 PM

try $_GET instead of $HTTP_GET_VARS
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 Tatara

Tatara
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 17 August 2006 - 05:33 PM

Whats the difference?
What i want is to be able to call the image from http://www.mysite.com/user.png wher it takes the name of the ping and queries the database for that user and return the info.

#4 Gobiggi

Gobiggi
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 August 2006 - 09:56 PM

$_GET is the same but has replaced $_HTTP_GET_VARS in newer php version

ps. this is supposed to be a help forum so why are you people replying once and then never answering any more questions!? you did that to me before! and as a help forum i rate you 2/10

#5 Tatara

Tatara
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 17 August 2006 - 10:00 PM

youngcoders.com is a good help site but i never got the activation email
any ways thanks for answering

#6 Gobiggi

Gobiggi
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 August 2006 - 11:03 PM

you are most welcome

#7 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,015 posts

Posted 18 August 2006 - 12:10 AM

ps. this is supposed to be a help forum so why are you people replying once and then never answering any more questions!? you did that to me before! and as a help forum i rate you 2/10


Because when, after less than an hour had passed, you demanded that I hurry with a solution I decided to walk away. You aren't paying and I'm not on your time. I volunteer my time here and decided I'd rather spend it helping someone else after your outburst. A little more patience and you would have had a solution.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users