duanmu3049 2014-01-08 12:27
浏览 44
已采纳

从PHP数组中获取值并在选择href时显示它

I have the following php code below. I would like that when the user hits the Delete Now button - the picture value is displayed. Regardless of which any button I select the picture05 gets displayed.

I may have a problem getting the selected value from the foreach to the echo code below

<?php
$pic_names = array (
    '01' => 'picture01',
    '02' => 'picture02',
    '03' => 'picture03',
    '04' => 'picture04',
    '05' => 'picture05',
);

foreach($pic_names as $pic_key => $pic_value){
echo '<a href="?delete=';
echo $pic_value;
echo '">Delete Now!</a><br/>';
}

//Delete Images
if(isset($_GET['delete'])){
echo $pic_value;
}
?>
  • 写回答

5条回答 默认 最新

  • doujia3441 2014-01-08 12:29
    关注

    Try this:

    foreach($pic_names as $pic_key => $pic_value){
         echo '<a href="?delete='.$pic_value.'">Delete Now!</a><br/>';
    }
    

    In you code you make checking GET but echo another variable, try this:

    if(isset($_GET['delete'])){
       echo $_GET['delete'];
    } 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度