PHP包含JS表不起作用?

时间:2016-02-24 13:20:01

标签: javascript php jquery html

所以我有一个用户页面,其中我包含了几个表,其中一个表使用了由javascript处理的分页脚本(因此我不必在查看页面时刷新页面)现在我是试图将此包含在我的user.php页面上,但它似乎没有用,任何帮助赞赏

User.php页面



<?php require 'session.php';
require 'header.php';
require 'includes/database.php';
    $userid = $_GET['id'];
$con = mysql_connect($servername, $username, $password);
  if(!$con) {
    die('Could not connect: ' . mysql_error());
  }
mysql_select_db($dbname);
//CLIENT INFO TABLE
include 'user/clientinfo.php';

echo "<br>";

// XLRSTATS TABLE
include 'user/xlrstatsinfo.php';

echo "<br>";

//ALIAS TABLE
include 'user/aliases.php';

//IP TABLE
include 'user/ipaliases.php';

//PENALTY TABLE
include 'user/penalties.php';

//PENALTY TABLE
include 'user/userchatlog.php';

?>
&#13;
&#13;
&#13;

userchatlog.php页面

&#13;
&#13;
<?php
require '../session.php';
?>
<div id='retrieved-data'>
	<!-- 
	this is where data will be  shown
	-->
    <img src="../images/ajax-loader.gif" />
</div>
<link rel="stylesheet" type="text/css" href="http://144.76.158.173/ech/includes/css/main.css" />
<script type = "text/javascript" src = "../includes/js/jquery-1.7.1.min.js"></script>
<script type = "text/javascript">
$(function() {
	//call the function onload
	getdata( 1 );
});

function getdata( pageno ){                     
	var targetURL = '../includes/pagination/userchatlog/search_results.php?page=' + pageno;   

	$('#retrieved-data').html('<p><img src="../images/ajax-loader.gif" /></p>');        
	$('#retrieved-data').load( targetURL ).hide().fadeIn('slow');
}      
</script>
&#13;
&#13;
&#13;

和我的search_results.php

&#13;
&#13;
<!-- include style -->
<link rel="stylesheet" type="text/css" href="http://144.76.158.173/ech/includes/css/main.css" />
<?php
//open database
include '../../database.php';
//include our awesome pagination
//class (library)
include 'ps_pagination.php';

//connect to mysql server
$mysqli = new mysqli($servername, $username, $password, $dbname);

//check if any connection error was encountered
if(mysqli_connect_errno()) {
    echo "Error: Could not connect to database.";
    exit;
}
function _ago($tm,$rcs = 0) {
   $cur_tm = time(); $dif = $cur_tm-$tm;
   $pds = array('second','minute','hour','day','week','month','year','decade');
   $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600);
   for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]);

   $no = floor($no); if($no <> 1) $pds[$v] .='s ago'; $x=sprintf("%d %s ",$no,$pds[$v]);
   if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm);
   return $x;
}
//query all data anyway you want
$sql = "SELECT * FROM chatlog WHERE msg NOT LIKE '%RADIO%' ORDER BY id DESC";

//now, where gonna use our pagination class
//this is a significant part of our pagination
//i will explain the PS_Pagination parameters
//$conn is a variable from our config_open_db.php
//$sql is our sql statement above
//3 is the number of records retrieved per page
//4 is the number of page numbers rendered below
//null - i used null since in dont have any other
//parameters to pass (i.e. param1=valu1&param2=value2)
//you can use this if you're gonna use this class for search
//results since you will have to pass search keywords
$pager = new PS_Pagination( $mysqli, $sql, 45, 4, null );

//our pagination class will render new
//recordset (search results now are limited
//for pagination)

$rs = $pager->paginate(); 

//get retrieved rows to check if
//there are retrieved data
$num = $rs->num_rows;

if($num >= 1 ){
	//creating our table header
	echo "<table id='my-tbl'>";
	echo "<tr>";
		echo "<th>Time</th>";
		echo "<th>Name</th>";
		echo "<th>Message</th>";
	echo "</tr>";
	
	//looping through the records retrieved
	while( $row = $rs->fetch_assoc() ){
$msg=$row['msg'];
$team=$row['client_team'];
$team = str_replace("42","<img src=images/green.png>",$team);
$team = str_replace("3","<img src=images/red.png>",$team);
$team = str_replace("2","<img src=images/blue.png>",$team);
$team = str_replace("1","<img src=images/grey.png>",$team);
$msg = str_replace("^0","</font><font color=black>",$msg);
$msg = str_replace("^1","</font><font color=red>",$msg);
$msg = str_replace("^2","</font><font color=lime>",$msg);
$msg = str_replace("^3","</font><font color=yellow>",$msg);
$msg = str_replace("^4","</font><font color=blue>",$msg);
$msg = str_replace("^5","</font><font color=aqua>",$msg);
$msg = str_replace("^6","</font><font color=#FF00FF>",$msg);
$msg = str_replace("^7","</font><font color=white>",$msg);
$msg = str_replace("^8","</font><font color=white>",$msg);
$msg = str_replace("^9","</font><font color=gray>",$msg);
$name=$row['client_name'];
$name=htmlentities($name);
$time=$row['msg_time'];
		echo "<tr class='data-tr' align='center'>";
	echo "<td align=center>";
	echo _ago($time);
	echo "</td>";
	echo "<td align=center>";
	echo $team;
	echo "<a href='http://144.76.158.173/ech/user.php?id=".$row["client_id"]."' > $name </a></td>";
	echo "<td align=left> $msg </td>";
	echo "</tr>";
	}       
	
	echo "</table>";
}else{
	//if no records found
	echo "No records found!";
}
//page-nav class to control
//the appearance of our page 
//number navigation
echo "<div class='page-nav' align='center'>";
	//display our page number navigation
	echo $pager->renderFullNav();
echo "</div>";

?>
&#13;
&#13;
&#13;

0 个答案:

没有答案