|
|
|
|
![]() ![]() |
Jul 25 2005, 12:35 AM
Post
#1
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 86 Joined: 10-June 05 Member No.: 8,063 |
Hello, i need tu put in $width (a php variable), the screen width of the client, and then do some arithmetics operations with it,
I did this : CODE $width = " <script>document.write(screen.width); </script>"; I tested if $width get the value, with this: echo $width; And, is ok, but when i multiply $width with any value, I got $width = 0; example; My Screen is at 1024 by 768 so: $width = "<script>document.write(screen.width); </script>"; echo $width; ---------------> 1024 $width = $width * 2; echo $width; ------------------> 0 Please, Can someone tell me why? and is there a manner to do this!! Thank's kservice This post has been edited by Johnny: Jul 25 2005, 06:47 AM |
|
|
|
Jul 25 2005, 06:43 AM
Post
#2
|
|
|
Incest is a game the whole family can play. ![]() Group: [MODERATOR] Posts: 1,217 Joined: 11-February 05 From: Heaven Member No.: 3,709 |
One possible solution seems simple
CODE $width = $width + $width; and for $width * 3 do CODE $width = $width + $width + $width; |
|
|
|
Jul 25 2005, 06:56 AM
Post
#3
|
|
|
Ephesians 6:10-17 ![]() Group: [MODERATOR] Posts: 1,893 Joined: 22-June 05 From: The World of Gentoo Member No.: 8,528 ![]() |
Welp, i can tell you why it doesnt work the way you want it to. Reason being, it's impossible to multiply <script>document.write(screen.width); </script> by any number. $width has to equal an integer in order for it to be multiplied, or whatever.
|
|
|
|
Jul 25 2005, 08:16 AM
Post
#4
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,114 Joined: 28-May 05 From: Hertfordshire, England Member No.: 7,593 ![]() |
truefusion is right. The variable $width is not holding a number but is holding a text string. PHP cannot multiply a text string by two, so it returns 0.
After a short time searching on the web I have cobbled together a system that could work, although I have had no time to try it. Create an HTML page with the following code in it: CODE <html> <head> </head> <body> <script> window.location="page.php?height="+screen.height+"&width="+screen.width; </script> </body> </html> Then on the page called page.php (feel free to change it in the script above): CODE <?php $height = $_GET['height']; $width = $_GET['width']; //Now the rest of your page... In page.php the variables should now hold the screen resolution. If you want to check then just echo those variables and see what you get. Good luck |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th September 2008 - 08:36 PM |