douji1877 2014-06-03 01:50
浏览 7

我可以重定向到我当前的php页面,但具有不同的功能(基于用户的决定)? [关闭]

Basically, I have a function that creates a calendar and only needs modifying to display the next/prev month in a calendar ie. createCal($nextM, $y) and I just need to call this function with the new parameters whenever someone clicks a link. I don't think we can use javascript so i'd like to avoid that if at all possible.

Pretty much, all i want to do is something like--

if (user clicks on 'next') then 
    createCal($nextM, $y) 
else if (user clicks on 'prev') then 
    createCal($prevM, $y)

^is there anything I can do like this above? Thanks!

  • 写回答

1条回答 默认 最新

  • dongshu9458 2014-06-03 02:08
    关注

    There are lots of ways to do this. One suggestion is to use a $_GET parameter to send the month you want to display. Something like:

    PHP:

    if (isset($_GET['month'])) {
         createCal($_GET['month'], $y)
    }
    

    HTML:

    <a href='cal.php?month=<?=$nextM?>'>Next Month</a>
    <a href='cal.php?month=<?=$prevM?>'>Prev Month</a>
    

    Depending on your system, you might also want to send the year - for situations where next month is Jan of the next year, or previous month is Dec last year...

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器