簡體   English   中英

如何將圖像地圖區域ID發送到php文件?

[英]How can i send an image map area id to a php file?

我有一個圖像地圖,顯示存儲在MySQL數據庫中的不同類型食物的類別。 類別底部的每個節點都是圖像地圖上的一個區域,當我單擊該區域時,我希望它將該產品的相關產品ID發送到名為show_products.php的php文件中,該文件將顯示該產品的詳細信息(即價格,庫存,名稱等。)

我的影像圖

<map name="frozen">
        <area coords="88,172,6,130" shape="rect" id="1001"> 
        <area coords="61,247,143,291" shape="rect" id="1002">
        <area coords="196,132,278,172" shape="rect" id="1003">
        <area coords="237,289,155,249" shape="rect" id="1004">
        <area coords="336,288,253,248" shape="rect" id="1005">
        <area coords="349,248,430,289" shape="rect" id="1006">
    </map>

我試圖將地圖封裝成表格並通過javascript提交POST數據,但是我的其他php文件仍然不會收到與每個區域相關聯的ID。 我如何將這些唯一的產品ID發送到另一個php文件,用戶在該文件中單擊相關區域,並且show_products.php頁面將顯示所選產品的所有詳細信息? 有比使用ID手動尋址每個區域更有效的方法嗎?

任何幫助將不勝感激。

謝謝。

您可能會將href屬性添加到您的<area>元素,並通過php添加ID?

<area coords="88,172,6,130" href="show_products.php?id=<?= $product_id ?>" shape="rect" id="1001">

然后在show_products.php中通過執行以下操作獲取ID

$product_id = $_GET["id"];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM