Note that there are some explanatory texts on larger screens.

plurals
  1. POGrabbing screen resolution and displaying results based on the size
    primarykey
    data
    text
    <p>I'm trying to show results from a database based on screen resolution size. I posted a question last week about how to get the width and was able to come up with this jquery with the help of a few ideas here, but was unable to complete the second aspect, which is to display results based on the size: </p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { var $window = $(window); function checkWidth() { var windowsize = $window.width(); if (windowsize = 1600) { //**This is where I need to define the $maxresults value, but how?** } } // Execute on load checkWidth(); // Bind event listener $(window).resize(checkWidth); }); &lt;/script&gt; </code></pre> <p>Now, this is the second part:</p> <pre><code>&lt;?php // get the function include_once ('function.php'); $maxresults = 21; if ($_GET['page']) { $page = $_GET['page']; } else { $page = 0; } $currentpage = $page; $page = $page*$maxresults; $numpages = QuickQuery("SELECT COUNT(id) FROM books WHERE visible=1"); $numpages = mysql_result($numpages, 0); $numpages = $numpages/$maxresults-1; //Show &lt;maxresults&gt; pages at a time $result = GetBooksByRangeID($page, $maxresults); DisplayResults($result); ?&gt; </code></pre> <p>The max amount of results to show is set to 21, but I want to use the jquery above to define the amount based on a user's screen resolution; I will have various sizes. In other words, I need the if statement to say "show this many results based on the size found." So how do I write that if statement? </p> <p>*<strong>LAST REVISION= Partially WORKING, (sets all results to max 6 despite resolution size) *</strong></p> <pre><code>&lt;?php // get the function include_once ('function.php'); if(($_GET['w']) &amp;&amp; ($_GET['h'])) { $w = $_GET['w']; $h = $_GET['h']; } if ($w == 1920) { $maxresults = 24; } else if ($w == 1600) { $maxresults = 24; } else if ($w == 1440){ $maxresults = 12; } else if ($w == 1366) { $maxresults = 10; } else if ($w == 1024) { $maxresults = 8; } else $maxresults = 6; </code></pre> <p>.....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload