dtjzpg5313 2011-07-16 16:03
浏览 12
已采纳

使用$ _GET通过循环自动创建多个页面

please look the following code:

<?php
if ($_GET['picture'] == 1) {
    echo "<img src=\"1.jpg\" />";
} else if ($_GET['picture'] == 2) {
    echo "<img src=\"2.jpg\" />";
} else if ($_GET['picture'] == 3) {
    echo "<img src=\"3.jpg\" />";
}
?>

Now, when I click a link like index.php?picture=1, the picture 1.jpg will appear. But, when I have a thousand of these, I don't want to create every If statement myself: so how to I loop through this? How can I create a loop so these are automatically created?

  • 写回答

3条回答 默认 最新

  • dozpv84422 2011-07-16 16:05
    关注

    You can include the value inside of the echo'd string. Just check to make sure its less than your maximum (1000 or whatever):

    $picture = intval($_GET['picture']);
    if (picture > 0 && $picture < maximum) {
      echo "<img src=\"{$picture}.jpg\" />";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测