I want to create a responsive section for products but I ran into a problem when I tried to get DOM offsetWidth.
Basically I have an SQL statement which should show the selected items but I want to LIMIT
the number of results. The LIMIT
should be calculated by the container width and division of the product cointainers width which is 172 (= the width of the products container. These containers have the fixed 172px width).
My only problem is that I couldn't figure out how to get the DOM width using PHP. I have managed to get the width using javascript offsetWidth
but I couldn't pass this value to the PHP SQL statement.
Any idea how to get the DOM elements width or pass javascript values to PHP?
$offset = (round(1302/176)*2)-1
SELECT * FROM table WHERE condotion LIKE "TRUE" LIMIT $offset;
PS: The $offset
calculation: 1302
: the width of the main container which is divided by 172
(fixed value) AND *2
-> it doubles the result so I'll have two rows. AND the -1
is for to delete the last elements because I want to replace it with somethins else.