You need to pass the screen width in numeric format to $screenwidth . Is this possible in this example? Or do you need to transfer to $_GET['width'] and take values ​​from there? Thank.

 $screenWidth= '<script> document.write(screen.width); </script>'; if ( $screenWidth >= 1367) { $num_of_adds = 15; $num_of_td = 3; } else { $num_of_adds = 10; $num_of_td = 2; } 

    2 answers 2

    This is a silent horror.
    First, the code in $screenWidth will never be executed, for different languages.
    Secondly, counting the number of lines, cells, hair on the user's head in PHP is just nonsense. This should deal with CSS with its Media queries .
    Third, the transfer of values ​​from JS to PHP if strongly needed (not in this case, true), that is, the HTTP methods: GET, POST, DELETE, etc.
    Example.

      You can try in JS, the expansion of the screen to write to cookies. And then with the help of php pull this extension from the cookie.