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.
screen size change?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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.can i do it all in php?
Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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:
Mac
Code: Select all
if ($screensize > 1024) {
header('location:default.php');
} elseif ($screensize < 1024) {
header('location:default2.php');
}-
gavinbsocom
- Forum Commoner
- Posts: 71
- Joined: Tue Sep 30, 2003 9:51 pm
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)?
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)?
-
gavinbsocom
- Forum Commoner
- Posts: 71
- Joined: Tue Sep 30, 2003 9:51 pm