我有一個(gè)用于汽車(chē)零件的 PhP 購(gòu)物車(chē),我需要能夠在單擊它時(shí)放大檢索到的圖像。問(wèn)題是我無(wú)法為每張圖片手動(dòng)分配 ID,因?yàn)槲艺趶臄?shù)據(jù)庫(kù)中回顯它們。我已經(jīng)嘗試為所有檢索到的圖片分配一個(gè) ID/類(lèi),并使用 JS 功能在單擊時(shí)放大它們,但無(wú)法使其正常工作。 $items_array = $db_controller->runQuery("SELECT * FROM mystuff ORDER BY ID ASC"); if (!empty($items_array)) { foreach($items_array as $key=>$value){ ?> <div class="DisplayCartItems"> <form method="post" action="?action=add&mscode=<?php echo $product_array[$key]["mscode"]; ?>"> <img src="<?php echo $product_array[$key]["msimage"]; ?>" class="imgcartdisplay" align="alignnone"/> /* Right here I need some help */ <div class="lif"><strong>Category:</strong> <?php echo $product_array[$key]["mscategory"]; ?></div> <div class="lif"><strong>Category №:</strong> <?php echo $product_array[$key]["mscatnum"]; ?></div> <div class="lif"><strong>Stock №:</strong> <?php echo $product_array[$key]["msnomer"]; ?></div> <div class="lif"><strong>Mark:</strong> <?php echo $product_array[$key]["msmark"]; ?></div> <div class="lif"><strong>Model:</strong> <?php echo $product_array[$key]["msmodel"]; ?></div> <div class="lif"><strong>Year:</strong> <?php echo $product_array[$key]["msyear"]; ?></div> <div class="lif"><strong>Price:</strong> <?php echo "$".$product_array[$key]["msprice"]; ?></div> <div style="text-align:center"><input type="number" name="oap" placeholder="Offer a price:"></div> <br class=""> <div class="cartan"> Quantity: <input type="text" class="product-quantity" name="quantity" value="1" size="2" /> <br class=""> <input type="submit" onclick="AddCartAlert()" value="Add to cart" /></div> </form> </div> <?php } } ?>```I think if I can somehow assign an ID or class name for every picture that get displayed from the MySql and onclick change it's width/height, that'd do the job.
通過(guò)回聲自動(dòng)從 mysql 檢索許多圖像并在單擊時(shí)放大它們
狐的傳說(shuō)
2021-07-07 13:48:33