What I want to do is to make my site get the current width of the window that the visitor has. Then I want to have two different options. Something like this:
<script>
if (screen.width < 768) {
<?php $a = 1; ?>
} else {
<?php $a = 2; ?>
}
</script>
What I'm trying to do is that my php variable should change based on device width.
Which way is the easiest way to do this? I can't write or understand a single row of AJAX so if that's the only way I would be very satisfied with some kind of guide to make this as easy as possible.
And to make it with CSS is not the right way. So please, don't tell me something that has to got anything to do with CSS.
Edit:
I'm not sure if you guys understand what I really want to get out of this code.
So I will write it more specific.
I have a site which has an image-slider on top that shows the 2 latest news. Right under this I have a query of posts that are set to offset 2, because I don't want to query the same news that I have in my slider.
So my code is something like this:
<?php
$offset = 2;
$showposts = 10;
?>
<?php query_posts(array('offset' => $offset, 'showposts' => $showposts,'cat' => '8')); ?>
And I can't make two different queries because I have ad-scripts that can't be loaded more than 1 time, because then they will not show at all. So it all need to be done in one query, and that's why it has to be changed based on device width.
Now I forgot to tell that on my version for width < 768 I make my slider disappear and therefore I want to have the offset to 0 instead of 2.
I hope this makes more sense...