Normano
May 25 2008, 06:11 PM
Im working on a dynamic image, can i put 2 images in same dynamic image, and can i make this code shorter? CODE if ( $goal == 31 ) { $xp2 = ('14833'); } elseif ( $goal == 32 ) { $xp2 = ('16456'); } elseif ( $goal == 33 ) { $xp2 = ('18247'); } elseif ( $goal == 34 ) { $xp2 = ('20224'); } elseif ( $goal == 35 ) { $xp2 = ('22406'); } elseif ( $goal == 36 ) { $xp2 = ('24815'); } elseif ( $goal == 37 ) { $xp2 = ('27473'); } elseif ( $goal == 38 ) { $xp2 = ('30408'); } elseif ( $goal == 39 ) { $xp2 = ('33648'); } elseif ( $goal == 40 ) { $xp2 = ('37224'); } elseif ( $goal == 41 ) { $xp2 = ('41171'); } elseif ( $goal == 42 ) { $xp2 = ('45529'); } elseif ( $goal == 43 ) { $xp2 = ('50339'); } elseif ( $goal == 44 ) { $xp2 = ('55649'); } elseif ( $goal == 45 ) { $xp2 = ('61512'); } elseif ( $goal == 46 ) { $xp2 = ('67983'); } elseif ( $goal == 47 ) { $xp2 = ('75127'); } elseif ( $goal == 48 ) { $xp2 = ('83014'); } elseif ( $goal == 49 ) { $xp2 = ('91721'); } elseif ( $goal == 50 ) { $xp2 = ('101333'); } elseif ( $goal == 51 ) { $xp2 = ('111945'); } elseif ( $goal == 52 ) { $xp2 = ('123660'); } elseif ( $goal == 53 ) { $xp2 = ('136594'); } elseif ( $goal == 54 ) { $xp2 = ('150872'); } elseif ( $goal == 55 ) { $xp2 = ('166636'); } elseif ( $goal == 56 ) { $xp2 = ('184040'); } elseif ( $goal == 57 ) { $xp2 = ('203254'); } elseif ( $goal == 58 ) { $xp2 = ('224466'); } elseif ( $goal == 59 ) { $xp2 = ('247886'); } elseif ( $goal == 60 ) { $xp2 = ('273742'); } elseif ( $goal == 61 ) { $xp2 = ('302288'); } elseif ( $goal == 62 ) { $xp2 = ('333804'); } elseif ( $goal == 63 ) { $xp2 = ('368599'); } elseif ( $goal == 64 ) { $xp2 = ('407015'); } elseif ( $goal == 65 ) { $xp2 = ('449428'); } elseif ( $goal == 66 ) { $xp2 = ('496254'); } elseif ( $goal == 67 ) { $xp2 = ('547953'); } elseif ( $goal == 68 ) { $xp2 = ('605032'); } elseif ( $goal == 69 ) { $xp2 = ('668051'); } elseif ( $goal == 70 ) { $xp2 = ('737627'); } elseif ( $goal == 71 ) { $xp2 = ('814445'); } elseif ( $goal == 72 ) { $xp2 = ('899257'); } elseif ( $goal == 73 ) { $xp2 = ('992895'); } elseif ( $goal == 74 ) { $xp2 = ('1096278'); } elseif ( $goal == 75 ) { $xp2 = ('1210421'); } elseif ( $goal == 76 ) { $xp2 = ('1336443'); } elseif ( $goal == 77 ) { $xp2 = ('1475581'); } elseif ( $goal == 78 ) { $xp2 = ('1629200'); } elseif ( $goal == 79 ) { $xp2 = ('1798808'); } elseif ( $goal == 80 ) { $xp2 = ('1986068'); } elseif ( $goal == 81 ) { $xp2 = ('2192818'); } elseif ( $goal == 82 ) { $xp2 = ('2421087'); } elseif ( $goal == 83 ) { $xp2 = ('2673114'); } elseif ( $goal == 84 ) { $xp2 = ('2951373'); } elseif ( $goal == 85 ) { $xp2 = ('3258594'); } elseif ( $goal == 86 ) { $xp2 = ('3597792'); } elseif ( $goal == 87 ) { $xp2 = ('3972294'); } elseif ( $goal == 88 ) { $xp2 = ('4385776'); } elseif ( $goal == 89 ) { $xp2 = ('4842295'); } elseif ( $goal == 90 ) { $xp2 = ('5346332'); } elseif ( $goal == 91 ) { $xp2 = ('5902831'); } elseif ( $goal == 92 ) { $xp2 = ('6517253'); } elseif ( $goal == 93 ) { $xp2 = ('7195629'); } elseif ( $goal == 94 ) { $xp2 = ('7944614'); } elseif ( $goal == 95 ) { $xp2 = ('8771558'); } elseif ( $goal == 96 ) { $xp2 = ('9684577'); } elseif ( $goal == 97 ) { $xp2 = ('10692629'); } elseif ( $goal == 98 ) { $xp2 = ('11805606'); } elseif ( $goal == 99 ) { $xp2 = ('13034431'); } else { $xp2 = ('0'); }
Reply
vujsa
May 26 2008, 04:18 AM
Yes, you can have multiple images in your dynamic image. It has been a while since I've done dynamic images so I won't try to code it for you today but I'll explain how it normally works. You normally start your dynamic image script by loading a background image or setting a blank or solid colored image with imagecreate() or similar function. You then add an image over the top of that image with imagecopy() or similar function. You can then use image copy again and again and it will insert the part of the image to use into your new image where you specify. Each new image inserted will be layered on top of what ever already exists in the dynamic image. So you can imagecopy() a a button or some other image segment then do another imagecopy() to place a border around that etc... Now, for your second question... You could use a switch! CODE switch ($goal) { case 31: $xp2 = ('14833'); break; case 32: $xp2 = ('16456'); break; case 33: $xp2 = ('18247'); break; // etc... } Not particularly better... I would use an array. CODE $xp_array = array(14833, 16456, 18247, 20224, 22406); // etc...
$xp2 = $xp_array[$goal - 31]; In this case, $xp_array[0] = 14833;So to get to get the zero index, we have to subtract 31 from $goal right! As a result, $xp_array[1] = 16456;Because 32 - 31 = 1 I hope you understand how this works. The array index starts at zero but your scale starts at 31. To get your scale to match the array index, you have to subtract 31. As a result, the following is true: 0 = 31 = 14833 1 = 32 = 16456 2 = 33 = 18247 3 = 34 = 20224 4 = 35 = 22406 You may then want to have a check to see if the value of $goal is below 31 or above 99 and act accordingly. Good luck vujsa
Reply
Normano
May 26 2008, 04:11 PM
Thanks very much, its works good and it faster now CODE $xp_array = array(14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, 899257, 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 13034431); $xp2 = $xp_array[$goal - 31]; I gonna try imagecopy().
Reply
vujsa
May 26 2008, 08:45 PM
QUOTE(Normano @ May 26 2008, 12:11 PM)  Thanks very much, its works good and it faster now CODE $xp_array = array(14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, 899257, 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 13034431); $xp2 = $xp_array[$goal - 31]; I gonna try imagecopy(). I'm glad that I could help. Yeah, the script should run much faster now. It is amazing how much easier and quicker a script can run just by changing the code a little bit. Before, the server had to check 68 conditional statements (if, else if, else) but now it only looks for one specific item in an array. If I had quickly found a pattern to the $xp2 values, it would be even quicker to do it all mathematically. Something like this: CODE $xp2 = $goal - 31 + 14833 + (($goal - 31) * .01); This of course isn't the correct formula but if you had a formula to use instead of an array, you would save even more lines of code and speed up the script. Good luck, vujsa
Reply
Normano
May 28 2008, 04:57 PM
I got a small problem, when It load the background on the dynamic image, if the image file dont exist it say error in the image, do u remember or know how to fix it? I use CODE $im = imagecreatefrompng("$string.png"); edit: If a varible is more then 100, can i do so it change to 100?
Reply
vujsa
May 29 2008, 04:48 AM
QUOTE(Normano @ May 28 2008, 12:57 PM)  I got a small problem, when It load the background on the dynamic image, if the image file dont exist it say error in the image, do u remember or know how to fix it? I use CODE $im = imagecreatefrompng("$string.png"); edit: If a varible is more then 100, can i do so it change to 100? No problem, just check for the image first... CODE if (file_exists($string.png)) { $im = imagecreatefrompng("$string.png"); } This way the image copy is only attempted if the image exists. As for your 100 question, I assume you mean if $goal for some reason is larger than 99... Let's say that a $goal of 99 is the maximum so if a number is larger than that, it should be reset to 99 and maybe 31 is the minimum so reset $goal below that to 31 like so: CODE if($goal > 99){ $goal = 99; } else if ($goal < 31){ $goal = 31; } $xp_array = array(14833, 16456, 18247, 20224, 22406); // etc...
$xp2 = $xp_array[$goal - 31]; I hope this answers your questions. vujsa
Reply
Normano
May 30 2008, 03:35 PM
Thanks very much:)  its work good:)
Reply
vujsa
Jun 1 2008, 12:25 PM
QUOTE(Normano @ May 30 2008, 11:35 AM)  Thanks very much:)  its work good:)  Glad to hear that this resolved your issues. I look forward to your future PHP discussions. vujsa
Reply
Normano
Jun 1 2008, 07:21 PM
CODE if($goal < $lvl){ imagestring($im, 2, 150, 14, "Goal Reached, Congrats!", $black); imagestring($im, 2, 149, 13, "Goal Reached, Congrats!", $white); }else{ imagestring($im, 2, 150, 14, "XP Left: $xp_left", $black); imagestring($im, 2, 149, 13, "XP Left: $xp_left", $white); } this script do so if $lvl is bigger then $goal it say "Goal Reached, Congrats!" but if $goal and $lvl is same how do i code so it say "Goal Reached, Congrats!"? thanks for all help
Reply
vujsa
Jun 1 2008, 08:20 PM
QUOTE(Normano @ Jun 1 2008, 03:21 PM)  CODE if($goal < $lvl){ imagestring($im, 2, 150, 14, "Goal Reached, Congrats!", $black); imagestring($im, 2, 149, 13, "Goal Reached, Congrats!", $white); }else{ imagestring($im, 2, 150, 14, "XP Left: $xp_left", $black); imagestring($im, 2, 149, 13, "XP Left: $xp_left", $white); } this script do so if $lvl is bigger then $goal it say "Goal Reached, Congrats!" but if $goal and $lvl is same how do i code so it say "Goal Reached, Congrats!"? thanks for all help  Well, you would use "less than or equal to" instead of "less than". Here is your modified code: CODE if($goal <= $lvl){ imagestring($im, 2, 150, 14, "Goal Reached, Congrats!", $black); imagestring($im, 2, 149, 13, "Goal Reached, Congrats!", $white); }else{ imagestring($im, 2, 150, 14, "XP Left: $xp_left", $black); imagestring($im, 2, 149, 13, "XP Left: $xp_left", $white); } Here is some more information about comparison operators. http://us2.php.net/manual/en/language.oper....comparison.phpHope this helps, vujsa
Reply
Recent Queries:--
php image segment - 31.46 hr back. (1)
-
99 13,034,431 - 180.32 hr back. (1)
-
php generate codeimage - 303.00 hr back. (1)
Similar Topics
Keywords : dynamic php image php code- Activation Code
- (7)
- Php Random Selector
- whats the code (2)
Is there a PHP script that randomly selects a string from a list? example, the list is: 1-Pie
2-Balls 3-eggs The script would view a random
word from those 3 every time i run it. Also is there a function that gives a random number between
0 and a number i select?...
Dynamic Gd Image
- (2)
I dont know if someone already made a topic like this, however it's not hard to understand if
you can php, as many know we need to start a php script with CODE <?php and end with
CODE ?> to make a image you need a image type, I choos .png because its much cleaner then
.jpg CODE header("Content-type: image/png"); for the background for the
image we need this code CODE $image =
imagecreatefrompng("http://www.imagefilez.com/out.php/i252132_Userbar.png");
if we wont a text in the image we n...
Image Popup On Mouseover
- (23)
I need a script that does this: Lets say I have form with options...you surely know what that is...
CODE <form name="form2" method="post"
action="race.php?action=race"> <table border="1"><td>Who do you
wanna race?</td></table> <select size=5 name="bike">
<option value="Derbi Senda 50">Derbi Senda 50</option> <option
value="Honda NS 50 R">Honda NS 50 R</option> <option value="Suzuki
ZR 50">Suzuki ZR 50&...
Need Help With Background Image...
- (12)
I want to add background image to all sites on my website but some include "foot.php" and "head.php"
and some "footer.php" and "header.php" but all include "config.php" but i dont know in which should
i put it....any help??...
What's Wrong With My Php Webpage?
- there may be something wrong in my php code. (2)
This is the first time I use the functions fopen() and preg_replace() . It seems that there's
somthing wrong. Where did I write by mistake? CODE <?php
include('data/workinfo/0.php'); $viewwork =
substr($work[0],0,249); /* HERE CAN'T WORK WELL! */ $newthread =
fopen("http://c8s2007.freetzi.com/bbs/new.php?action=article&digest=0&postdate=0&author=
1&fname=0&hits=0&replies=1&pre=6&num=10&length=35&order=1", "rb");
if(!$newthread){ $newthread = "...
How Can I Write PHP Code By This Formmail Html
- (5)
purpose is i want the information in the web page sent into my email. i just know that i need to use
php script to operate this action ,but i have no idea about this php code. so anyone can help me
please... thank you very much. ชื่อ
....................... ....... นามสกุล
....... ชื่อเล่น
วันเกิด 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 ...
Php :: Image Pixel Per Inch And Conversion
- Please Guide (1)
Hi Masters I want soemone to let me know (maybe through a good tutorial and/or PHP Sample Code)
the following : 1 - User will only allowed to upload images with minimum 120 and maximum 300 Pixel
Per Inches 2 - User will only allowed to upload JPG images, however, if Gif / BMB / PNG / ETC is
uploaded the script will convert that into jpg. 3 - If the Image's PPI is > 300 it will set
to 300. Please guide . I know this can'y be done by GD it requires ImageMagick, Pleae help
!!!!!!! ...
Image Works With Php And Gd
- (3)
Hi I have a 1 Big map. What i want is that the user will enter the latitude and longitude. the
script will show that location in the image. I know how to convert Image X,Y Coordinates into
Latitide and Longitude and vise versa. But there point is that the image is 1000x1000 wide but i
want to show only the particular region of that latitude / longitude in 300x300 image. means that
the PHP script will CROP wht Image (1000x1000) to 300x300. That way, the script will be shoing the
part of an image, not the whole image. please help !!...
Php :: Adding Image Over Image
- (5)
Hi Masters & Champions. I want some help regarding putting and image over some location (x pixel ,
y pixel) of an image. Here it is quite important to note that the mage which is Inserted over an
image must be clickable. Like for example suppose i put T on an image DD then the T must be
clickable. Please gudie as this is quite important for me . Thanks ...
Code Snippets Repository
- (0)
Well as everybody know in these forums people posts a lot of code snippets that could be organized
in a simple page or whatever, my question is if someone is interested to do it or if exists
something like that here at astahost. I think it would be very helpful for everybody as well to
keep things more organized. Best regards,...
How Do I Resize An Image On The Fly?
- (8)
I was wondering how I would go about resizing an image from a databse without saving it to a file.
CODE <? include("settings.inc.php");
$get_a=$_GET['a']; $get_b=$_GET['b'];
$get_width=$_GET['width'];
$get_height=$_GET['height']; $query="SELECT * FROM $get_a
WHERE id='$get_b'"; $result=mysql_query($query);
$image=mysql_result($result,0,"coverimg"); $size=mysql_...
Script For Viewing A Random Image Needed
- (3)
While browsing the web, I bumped into a script that I could really use, since it's different
from everything that I saw. Most scripts that view a random image contain a code that chooses an
image, and then puts the part into the page itself. However, on the www.greenplastic.com web
site (dedicated to Radiohead), in the top left corner there is a random image module. If you look at
the code, here's what is used: CODE <img
src="http://www.greenplastic.com/images/v75/random/random.php" width="125"
height="125" /> Now,...
Dynamic Site Design - Where Do I Start ?
- (7)
I am new to php. I have some programing background in html, javascript, and c++ but have never done
anything in php Can someone reccomend some good sites or books etc that can help someone who is
completely new? My ultimate goal is to make a game like/similar to ponyisland.net...
[PHP + MySQL] Separating The Results By Pages
- Simple code (0)
Hi! I will post here a code for separating the results of MySQL in pages. You ask: Why separete?
I answer: Imagin that you have 1523 results to display. I dont have to say anything. =P Here is it.
------------------------------------------------------------------- CODE <?php $conect
= mysql_connect("host","user","password"); $select_db =
mysql_select_db("database"); $query = "SELECT * FROM mytable";
$results = "15"; //Number of results displayed per page. if (!$p...
How Do I Make PHP Based Image Gallery Like This?
- Help Needed (20)
is it possible to make a page in php, with a url like this:
httq://www.mysite.com/viewer.php?http://www.mysite.com/galleries/01 (This is a sample link, read
below) so that in what i change the last part the gallery will change with it? so that i just have
to make one php-page and this page just shows all the imaes in the map thats in the url after the
questionmark?? thanks,...
Uploading Image Via Admin Menu?
- (2)
There's never much action in here. Here's a question for all you php guys out there.
Here's what I want. Let's say I create a simple administration menu for someone to
Add/Edit/Delete a record/item from a database. Now in the add function, let's say I want to
store a URL to a image. Rather than having to go in and FTP that image up on the server, how could
a person create a 'Browse' button and find that image on your harddrive, then create a
script to upload the image to the server? Just wondering how to do it, or if it could be done e...
What's Wrong With This Preg_replace Code?
- (2)
I have written a JavaScript that prompts auser for 5 table attributes for entry into the posting
area and it produces this: It is then passed through this preg_replace for display in the
preview or as a submission in a post: CODE $txt = preg_replace( "#\[table
bd=(.+?)bgc=(.+?)bdc=(.+?)cp=(.+?)cs=(.+?)\](.+
?)\[/table\]#is", "<table
border=\\1bgcolor=\\2bordercolor=\\3cellpadding=\\4cellspaci
ng=\\5>&...
Saving A Php Generated Image To The Server
- Help Needed Please (5)
I'm trying to create a script that will generate an image and send it back to the browser while
saving the same image to the server. I'm doing this because the image should be dynamically
generated but because of the load that would place on a server if the image happened to be requested
frequently, I've decided to build in a means to serve the static version of the image most of
the time. What isn't included here is the function that will check the age of the file in cache
directory and serve the static image if it is less than an hour old. This isn...
Any Tool/software For Php Code Generation ?
- Tool for code generator (3)
Where find any tool to generate PHP class?...
Php: Write Random Text As Image
- Having problems, help needed! (3)
I'm trying to create a script that writes text to an image. CODE
header("Content-type: image/png"); $_phrases = array( "Test
1", "Test 2", "Test 3", "Test 4", "etc." );
$_rand_phrase = $_phrases[rand(0,count($_phrases)-1)];
$_image = imagecreatefrompng("gmail.png"); $_user_width =
imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase); $_x_value =
(200-($user_width[2] + 113));...
Is It Possible To Create A String Image In Chinese
- (0)
CODE Using imageloadfont <?php $im = imagecreate(50, 20); $black =
imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255,
255, 255); imagefilledrectangle($im, 0, 0, 49, 19, $white); $font =
imageloadfont("04b.gdf"); imagestring($im, $font, 0, 0,
"Hello", $black); imagepng($im); ?> This is an example for
illustrating how to create a image including a string with a specific font. In the codes, a font
named ...
Php Reading And Writing To File
- the code is very esay (4)
this code to Read from file you can use this code in to make a small data base and it is very to
use CODE $fp = fopen ("file.txt", "r"); $bytes = 4;
$buffer = fread($fp, $bytes); fclose ($fp); print
$buffer; ------------------- to write to same file CODE $fp = fopen
("file.txt", "w+"); fwrite ($fp, "Test"); fclose
($fp); ---------------- thanks and iwait the commant...
How To Use Cookie In Your Web Site ?
- this semple code to use and get cookie (1)
what is the cookie ? the cookis it is some info sent and save in user computer whare i can use the
cookies? becouse the cookies it like the header you can not send it after any output wes sent so
you must send the cookies before any output like as ,echo and any other code i well make an E.X.
to use the cookies you must have 2 file index.php update.php ---------- in the index.php add this
code CODE <? // This section must go at the top of the page that will display //
the users favorites. These are the 'default' URLs that the user // ...
Forum Signature-image With Php
- Use PHP to create an image in real-time (8)
With interest I have read these Topics. What I want to do with PHP is the following:
Signatue-image This is the Forum Signature of my cousin, who lives in Europe. The image is
generated in real-time. (Refresh the page, and see for yourself) My cousin refuses to tell me how
he did this. But I want to do the same thing, also with PHP. Any ideas? Greetings, John. This
is NOT a tutorial and in future you should be more careful about where you're posting your
threads. Moved to Programming > Scripting. ...
Random Image / Random Header
- S.O.S. (5)
im building a website, and i need some help i got 3 frames, navigation, top and main, but i want
the top banner to have a new tagline with every refresh, just like the header, it dont really matter
what coding it is, as long as it's not to weird /tongue.gif' border='0'
style='vertical-align:middle' alt='tongue.gif' /> ...
Page Doesn't Load When This Php Code Is Present ?
- (6)
CODE <?php switch($_GET['page']) { case "home";
include("index.php"); break; case "gallery";
include("gallery.php"); break; case "links";
include("links.php"); break; case "guestbook";
include("../guestbook/"); break; case "portfolio";
include("portfoilio.php"); break; case "other";
include("other.php"); brea...
Looking for dynamic, php, image, php, code, question
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for dynamic, php, image, php, code, question
|
advertisement
|
|