Page 1 of 1
screen size change?
Posted: Mon Oct 27, 2003 10:22 pm
by gavinbsocom
where and how would i put the code to choose a page depending on a persons screen size? can i do it all in php?
<?php
$switch = "screensize";
if screensize > 1024
header('location:default.php');
if screensize < 1024
header('location:default2.php');
endif
endif
?>
is something like that even possible, im new to this, and reading this book over and over.
Posted: Tue Oct 28, 2003 2:32 am
by twigletmac
can i do it all in php?
nope, you need to use JavaScript to find out the users resolution (just bear in mind that the resolution has no bearing on how big or small the user has made the browser window). If you search this forum for javascript and resolution then you'll find where others have asked the same or similar questions and received code snippets.
Mac
Posted: Tue Oct 28, 2003 2:34 am
by twigletmac
Try not to use the alternative syntax for control structures in PHP, very few people use it and braces are just so much clearer to read:
Code: Select all
if ($screensize > 1024) {
header('location:default.php');
} elseif ($screensize < 1024) {
header('location:default2.php');
}
Mac
Posted: Tue Oct 28, 2003 4:59 pm
by gavinbsocom
dont you hav eto close those if's?
Posted: Tue Oct 28, 2003 7:40 pm
by JAM
Nope. You do that by using the braces. if (X == Y) { <- start ... end -> }
PHP itself sees the start and end (so to speak).
I would take the opportunity to lift out that you should try to use the paranthesis also, as in Mac's example.
As Mac state, using alternate syntax is messy. And if you learn the correct way of typing (if I might say so) you will have much, much easier time spotting your own mistakes in the future. Trust me.
Do you happen to come from a background using VB(A)?
Posted: Tue Oct 28, 2003 10:27 pm
by gavinbsocom
k thankyou. Ill mess with the javascript portion of it, or i was thinking setting hte page = to like 700px so then if someone had 800 x 600 it fit them and if htey had 1024x 768 it fit them...