如何在php中检查图像是否被点击

发布于 2024-10-07 04:15:03 字数 520 浏览 0 评论 0原文

我的周期很少。这会将一些图像显示到屏幕上。每个图像都有一个 id,我将其存储在 $id 变量中。

当用户单击图像时,他们会看到一个弹出窗口。现在我使用查询字符串。当用户单击时,从查询字符串中获取带有 id 的弹出窗口。

但这不是一个好方法,因为如果用户使用查询字符串重新加载页面......他们每次都会弹出窗口。

显示弹出窗口时我需要 $id。如果没有查询字符串,我该如何做到这一点?如何检查是否单击了图像以及单击了哪张图像?

for j=1 .....{
...
..

 for i=1....... {
  $id=array[j,i];

   echo "<a href=test.php><img style='z-index:$z; position:absolute; left: $lf; top: $tf;' src='images/$src' width='$width' height='$heigth' title='$title' /></a>";


 }
}

I have little cycle. This take some image to the screen. Every image have an id which i stored in $id variable.

When user click on an image they get a popup window. Now im use query string. When user click, get a popup with id from query string.

But this is not a good way, 'coz if user reload the page, with the query string..they get the popup every time.

I need the $id when show the popup. How can i do this without querystring? How can i check if click on image and which image clicked on?

for j=1 .....{
...
..

 for i=1....... {
  $id=array[j,i];

   echo "<a href=test.php><img style='z-index:$z; position:absolute; left: $lf; top: $tf;' src='images/$src' width='$width' height='$heigth' title='$title' /></a>";


 }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

零度℉ 2024-10-14 04:15:04

您可以使用 JavaScript 在用户单击图像时触发弹出窗口。这样,就没有任何内容发送回服务器,并且没有查询字符串。

我看不到在页面上打印每张图片的 id 的位置,但因为它是伪代码,所以我假设它可以工作。使用 javascript 看起来像这样:

for j=1 .....{
  ...
  ..

 for i=1....... {
  $id=array[j,i];

   echo "<a href='javascript:alert(\"$id)\"'><img style='z-index:$z; position:absolute; left: $lf; top: $tf;' src='images/$src' width='$width' height='$heigth' title='$title' /></a>";

 }
}

单击图像将生成一个带有图像 id 的弹出窗口,并且不会将任何信息发送到服务器。

You can use JavaScript to trigger the popup when the user clicks on the image. This way, nothing is sent back to the server, and there is no query string.

I don't see where you print the id for each picture to the page, but because it is psuedocode, I'll assume it works. Using javascript would look something like this:

for j=1 .....{
  ...
  ..

 for i=1....... {
  $id=array[j,i];

   echo "<a href='javascript:alert(\"$id)\"'><img style='z-index:$z; position:absolute; left: $lf; top: $tf;' src='images/$src' width='$width' height='$heigth' title='$title' /></a>";

 }
}

Clicking on the image would then generate a popup with the id of the image, and no information would be sent to the server.

忆沫 2024-10-14 04:15:04

您可以放置​​一个函数,当有人单击图像时,该函数将增加计数器。并且该计数器将增加 1,您也可以将其设置到数据库中..

试试这个..
谢谢。

you can put one function that will be incremented counter when someone click on the image. and that counter will be increment by 1 and u can also set it into database..

Try this..
thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文