PDA

View Full Version : passing screen resolution to php



egyzaman
02-04-2015, 04:28 PM
hello
im not familiar with JavaScript and Ajax
simply i want to get the user screen resolution then make it as variable in php in the same page without refresh, i tried (document.write) and (Get) but it have problem with the pagination in the main script because it uses the url bar, also i tried to store by cookies, it also have problem that i must refresh the page to execute the code. below is the details:

im using wordpress custom index, what i need is get the user screen resolution to calculate how many posts per page will appear to him

this code is just example because i dont know how to really make it...


//php index.php
<script>
var x = screen.width;
var y = screen.height;
</script>
// send this variables to server_side
<?php
$width=(x); // this method might be ($_Post) coming from auto submitted form or even from database
if($width>=1024){
$posts_per_page=30;
}else{
$posts_per_page=20;
}
// -------rest of the code
?>


i need to do this not through ($_Get) from the url and without refreshing
i have been searching week ago without finding any solution because i cant understand java or ajax
please help
thanks in advance
and sorry for bad English