Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

Thread: Some Math Help Needed

1. Some Math Help Needed

Alright...so I'm making this poker web site and I need a bit of help displaying the chips when a bet is made. I currently am able to calculate how many of each denomination is needed to fulfill the bet, but I don't know how to go about displaying them.

My denominations are:

\$1, \$5, \$25, \$100, \$1000, \$5000, \$25000, \$100000

I then pass the bet amount to a function that provides me this information:

Array
(
[1] => 0
[5] => 1
[25] => 0
[100] => 7
[1000] => 0
[5000] => 0
[25000] => 0
[100000] => 0
)

This shows how many of each chip is needed to be displayed. On the page for this to be displayed I have two rows of ten stacks. Each stack contains six chips. Stacks are labeled from 0 to 9 and chips are labeled from 0 to 5.

I have tried for loops and such but just can't seem to get it to work correctly. Does anyone have any ideas?

Thanks a ton,

Troy

• I would take a CSS graphic approach to this:

In my example: http://www.catpin.com/poker/

View the HTML source of my example and see how the height
is altered in each <div> ... overflow is hidden.

This is the PHP script:
PHP Code:
``` <html><head><title>poker chip display</title><style>.col{background: url(chips.gif) no-repeat;height:428px;width:42px;float:left;overflow:hidden;}</style></head><body><?php\$onechip=42; // the height of one chip\$pile1 = array(4,10,2,5,3);foreach (\$pile1 as \$count){\$chips = \$onechip*\$count;echo"<div class='col' style='height:".\$chips."px;'></div> \n";}?></body></html> ```

I have one graphic image with all 10 chips.
I then only display a certain amount of the image by
cutting-off the image with "height" of the <div>.

This would render very fast and is easy to implement.

You of course create any graphic images of chips that you want.
They could be chips from a side-view, or top-view (like I did).

You could also do it horizontally by creating a horizontal graphic
and adjusting the width instead of height.

.

• That's pretty clever mlseim, a very novel approach even.

•

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•