PDA

View Full Version : Get somebodys name... count each letter, then draw a box 4 each letter... HOW?!?


l3vi
05-06-2003, 03:40 AM
I am trying to make a code where somebody just enters there name, and it will draw a box 4 each letter of there name... BUT! I cant figure out how 2 do that... Plz help me... This is all I have so far...


$Name = "$_POST[Name]";
$Name = ltrim($Name);
$Name = ucfirst($Name);
$amount = strlen($Name);

print("Your name contains $amount letters!<br>");

$im = imagecreate(200,50);
$white = imagecolorallocate($im,255,255,255);
$black = imagecolorallocate($im,0,0,0);
$blue = imagecolorallocate($im,189,199,299);
imagefill($im,0,0,$blue);

foreach ($Name as $amount){
ImageRectangle($im,0,0,25,25,$white);
}

But that doesnt seem to work... If you could tell me how to do this, I WOULD GREATLY APPRECIATE IT! :) :) :) :)

necros
05-07-2003, 12:50 AM
I'm not being funny or anything but can you not just output n boxes using img, in html ?
also if your going to do a print within the document that contains the images using the method below, each image must be called as a seperate resource, so that mime types can be set, etc.
Using something along the lines of <img src="/imgs/db_image.php?name=pieface">.

l3vi
05-07-2003, 01:15 AM
Yeah, I could...That would probably be the better way 2 go... But I also am thinking about once I get this down, 2 let them chose colors and everything... But still, how do I make it draw a box 4 each letter?

necros
05-07-2003, 01:24 AM
for($i=0; $i < count($_POST['name']); $i++) {
echo "<TABLE border="1">
<TR>
<TD>&nbsp;</TD>
</TR>
</TABLE>";
}

The html syntax may not be correct, but you should get the idea from the above.

let them chose colors and everything.
This should still be acheivable using only php.

l3vi
05-07-2003, 01:27 AM
Okay, thnx a bunch! :) Thankyou Thankyou THankyou! :) :) :)!

l3vi
05-07-2003, 01:44 AM
strlen($Name) works a bit better tho... the other way it counts arrays...:D

necros
05-07-2003, 02:07 AM
bah.. sorry about that.. I was working on a nested forloop for array recursion at the time.

l3vi
05-07-2003, 02:38 AM
lol. itsokay! :)