PHP使用DOM宽度进行计算

发布于 2025-01-30 08:24:22 字数 633 浏览 2 评论 0原文

我想为产品创建一个响应部分,但是当我尝试获得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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文