删除页面上显示的未知文本

时间:2015-02-16 17:01:31

标签: php html

我使用了一个名为addthisevent的小部件,允许用户在他们的日历中添加课程预订。它都是缩进的,但当我回显到页面的链接时,我会在按钮旁边随机显示“1”。正如您在此处所见 - http://oi60.tinypic.com/10fu8ac.jpg -

== add_event.php ==

<?php

//Call session variables
$start_time = $_SESSION['class_time_start'];
$end_time = $_SESSION['class_time_end'];
$date = $_SESSION['class_date'];
$class_name = $_SESSION['class_name'];
$client_F_name = $_SESSION['firstname'];
$client_L_name = $_SESSION['lastname'];
$client_email = $_SESSION['email'];

//echo addthisevent script
echo '<script type="text/javascript" src="https://addthisevent.com/libs/ate-latest.min.js"></script>';

//echo addthisevent with the variables in place, ready to be converted using the JS function
echo '<a href="http://example.com/link-to-your-event" title="Add to Calendar" class="  addthisevent" id="addthisevent">'
, 'Add to Calendar'
, '<span class="_start">' . $date . ' ' . $start_time . '</span>'
, '<span class="_end">' . $date . ' ' . $end_time . '</span>'
, '<span class="_zonecode">36</span>'
, '<span class="_summary">' . $class_name . ' Class</span>'
, '<span class="_description">Your ' . $class_name . ' class with ****</span>'
, '<span class="_location">*****</span>'
, '<span class="_organizer">*****</span>'
, '<span class="_organizer_email">******</span>'
, '<span class="_facebook_event">*****</span>'
, '<span class="_all_day_event">false</span>'
, '<span class="_date_format">YYYY/MM/DD</span>'
, '</a>';
?>

如果您需要更多代码,请告诉我,因为我知道这是一个奇怪的问题。

我真的无法解决导致它的原因。我知道它肯定来自上面的PHP。如果有办法解决这个问题,或者只是在页面加载后删除'1'作为一个很好的解决方法

由于

页面链接为http://217.37.5.115/content/temppage.php

您需要选择下拉框才能显示

简而言之:

我使用下面的这个函数来运行一个PHP脚本,当其中一个下拉框的值改变时

=== temppage.php(主页)===

<script>
    function class_space_Update(str) {
        if (str == "") {
            document.getElementById("class_spaces").innerHTML = "";
            return;
        } else {
            if (window.XMLHttpRequest) {
            //code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
            } else {
            //code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    document.getElementById("class_spaces").innerHTML = xmlhttp.responseText;
                    addthisevent.refresh();                                                
                }
            }

            xmlhttp.open("GET", "../includes/get/class_spaces.php?id=" + str, true);
            xmlhttp.send();

        }
    }
</script>

=== class_spaces.php ===

<?php
//Set session variables
//Session 'class_time_start'
$_SESSION['class_time_start'] = $start_time;

//Session 'class_time_end'
$_SESSION['class_time_end'] = $end_time;

//Session 'class_date'
$_SESSION['class_date'] = $date;

//Session 'space_left'
$_SESSION['space_left'] = $space_left;

//Include add_event.php
echo include_once ($_SERVER["DOCUMENT_ROOT"] . "/includes/add_event.php");

//Close MySQLi connection
mysqli_close($mysqli);
?>

这不是所有文件,因为它不是真的必要。

如果我注释掉echo include_once add_event.php部分,则不会出现'1'。

1 个答案:

答案 0 :(得分:1)

我能为您提供的快速解决方案是:

<?php

//Call session variables
$start_time = (isset($_SESSION['class_time_start']))?$_SESSION['class_time_start']:'';
$end_time = (isset($_SESSION['class_time_end']))?$_SESSION['class_time_end']:'';
$date = (isset($_SESSION['class_date']))?$_SESSION['class_date']:'';
$class_name = (isset($_SESSION['class_name']))?$_SESSION['class_name']:'';
$client_F_name = (isset($_SESSION['firstname']))?$_SESSION['firstname']:'';
$client_L_name = (isset($_SESSION['lastname']))?$_SESSION['lastname']:'';
$client_email = (isset($_SESSION['email']))?$_SESSION['email']:'';

//echo addthisevent script
ob_start();
echo '<script type="text/javascript" src="https://addthisevent.com/libs/ate-latest.min.js"></script>';

//echo addthisevent with the variables in place, ready to be converted using the JS function
echo '<a href="http://example.com/link-to-your-event" title="Add to Calendar" class="  addthisevent" id="addthisevent">'
, 'Add to Calendar'
, '<span class="_start">' . $date . ' ' . $start_time . '</span>'
, '<span class="_end">' . $date . ' ' . $end_time . '</span>'
, '<span class="_zonecode">36</span>'
, '<span class="_summary">' . $class_name . ' Class</span>'
, '<span class="_description">Your ' . $class_name . ' class with ****</span>'
, '<span class="_location">*****</span>'
, '<span class="_organizer">*****</span>'
, '<span class="_organizer_email">******</span>'
, '<span class="_facebook_event">*****</span>'
, '<span class="_all_day_event">false</span>'
, '<span class="_date_format">YYYY/MM/DD</span>'
, '</a>';
exit();