duandi8613 2017-10-30 21:26 采纳率: 100%
浏览 22

如何使用PHP将链接转换为按钮?

Can anyone skillful with PHP please help me with this question?

I want to essentially, convert a link into a button instead. Here is the relevant part of the code.

Basically, when the user clicks a different link (which is not relevant here), PHP will then generate another link called "Add Event" (this is the relevant one). It is the second line of this code that I am struggling to convert:

index.php

 if(isset($_GET['v'])){
     echo "<a href='".$_SERVER['PHP_SELF']."?month=".$month."&day=".$day."&year=".$year."&v=true&f=true'>Add Event</a>";
     if(isset($_GET['f'])){
         include("eventform.php");

It is attached to this file as well:

eventform.php

<form name='eventform' method='POST' action="<?php $_SERVER['PHP_SELF']; ?>?month=<?php echo $month;?>&day=<?php echo $day;?>&year=<?php echo $year;?>&v=true&add=true">

<table width='400px'>
    <tr>
        <td width='150px'>Title</td>
        <td width='250px'><input type='text' name='txttitle'> </td>
    </tr>

    <tr>
        <td width='150px'>Detail</td>
        <td width='250px'> <textarea name='txtdetail'> </textarea> </td>
    </tr>

<tr>
    <td td colspan='2'align='center'> <input type='submit' name='btnadd' value='Add Event'> </td>
</tr>
</table>

</form>

Basically, when you click the "Add Event" link, a form is generated. I want to essentially turn the "Add Event" link into an "Add Event" button. It will serve the same purpose- when the button is clicked, a form is generated. Thank you to anyone who can help.

  • 写回答

1条回答 默认 最新

  • douyuanqia665858 2017-10-30 22:01
    关注

    You could style the anchor tag to look like a button.

    On the second line of your code, add a class to the anchor element named btn like so:

    <a class="btn" //rest of your code>
    

    and then in your CSS file

    .btn {
         padding: 15px 30px;
         color: white;
         background: blue;
         border-radius: 5px;
    }
    

    When it is rendered out to the view, it should have the appearance of a button.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用