Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> How To Put Ina Php Var The Screen Width?
kservice
post 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

Notice from Johnny:
Added code tags.


This post has been edited by Johnny: Jul 25 2005, 06:47 AM
Go to the top of the page
 
+Quote Post
electriic ink
post Jul 25 2005, 06:43 AM
Post #2


Incest is a game the whole family can play.
Group Icon

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;
Go to the top of the page
 
+Quote Post
truefusion
post Jul 25 2005, 06:56 AM
Post #3


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,893
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528
T17 GFX Crew



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.
Go to the top of the page
 
+Quote Post
rvalkass
post Jul 25 2005, 08:16 AM
Post #4


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,114
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Take A Screen Shot Of Your Desktop.(22)
  2. Windows Xp Freezes At Welcome Screen(40)
  3. Max Table Width(13)
  4. Ie Table Width In A Div Tag(5)
  5. Ultima Online Graphics Tutorial(2)
  6. Geforce Fx 5200 Problems(5)
  7. Win Xp Freeze At Login Screen(4)
  8. [poll] Gears Of War(11)
  9. Windows Xp Issues(6)
  10. Small Screen(2)
  11. Changing The Windows Xp Splash Screen(10)
  12. Screen Resolutions?(3)
  13. Error Screen During Launch Of Game(0)
  14. Virtual Keyboard And Screen(8)
  15. Supervideocap(0)
  1. What Is The Best Screen Recorder?(5)
  2. The New Ipod Touch(10)
  3. Nasty Windows Tricks Using Vbs Codes(15)
  4. Screen Shot Of What My Website Will Look Like(30)
  5. Ipod Touch Help...(5)
  6. Rpg Maker 2003 Shifted Game Screen(3)
  7. Centering A Div Containing Image.(9)
  8. Lcd Screen Of Cellphone(3)
  9. Games Like The Ones You See On Touch Screen Machines(2)
  10. Speed Racer(2)
  11. Scroll And Pan The Screen Via Mouse In Flash(1)
  12. Centering A Div(0)
  13. How To Manually Turn Off Laptop Screen(5)


 



- Lo-Fi Version Time is now: 6th September 2008 - 08:36 PM