PHP使用DOM宽度进行计算
我想为产品创建一个响应部分,但是当我尝试获得DOM OffsetWidth时,我遇到了一个问题。
基本上,我有一个SQL语句,该语句应该显示所选项目,但我想limit
结果数量。 限制
应通过乘积偶有宽度的容器宽度和划分为172(=产品容器的宽度。这些容器具有固定的172px宽度)。
我唯一的问题是我无法弄清楚如何使用PHP获得DOM宽度。我设法使用JavaScript OffsetWidth
获得了宽度,但我无法将此值传递给PHP SQL语句。
知道如何将DOM元素宽度或将JavaScript值传递给PHP?
$offset = (round(1302/176)*2)-1
SELECT * FROM table WHERE condotion LIKE "TRUE" LIMIT $offset;
PS:$ offset
计算:1302
:主容器的宽度,该宽度除以172
(固定值)和*** 2
- >它使结果翻了一番,所以我有两行。 -1
是为了删除最后一个元素,因为我想用其他somethins替换它。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论