Tablesorter:table.tBodies [0]未定义(决定通过PHP MySQL检索表数据后)

时间:2012-03-17 21:52:31

标签: php jquery mysql tablesorter

我决定通过MySQL将表数据检索到tablesorter中,这导致出现此错误。

table.tBodies[0] is undefined

You can see a demo here:

如果有人感兴趣,这就是PHP的样子:

<?php

$dbuser = '';
$dbpass = '';
$dbname = '';  //the name of the database
$chandle = mysql_connect('localhost', $dbuser, $dbpass)
    or die('Connection Failure to Database');
mysql_select_db($dbname, $chandle) or die ($dbname . ' Database not found. ' . $dbuser);


date_default_timezone_set('Europe/Bratislava');
$currentHour = date('H');
if ($currentHour < 6) {
    // logical day started yesterday
    $PHP_START_DATE = strtotime('yesterday 06:00');
}
else {
    // logical day started today
    $PHP_START_DATE = strtotime('today 06:00');
}
$PHP_END_DATE = strtotime('tomorrow 05:59:59');

$DATE_START_SELECTED = date('Y-m-d H:i:s', $PHP_START_DATE);
$DATE_END_SELECTED = date('Y-m-d H:i:s', $PHP_END_DATE);


$query =    
"SELECT
    events.EVENT_NAME,
    events.start_datetime,
    events.end_datetime,
    events.VENUE_LOCATION,
    events.PARTY_TYPE,
    events.IMAGE_URL,
    events.ENTRANCE_PRICE, 
    venues.VENUE_NAME,
    venues.BEER_PRICE,
    venues.WINE_PRICE,
    SPIRITS_PRICE, 
    party_types.PARTYTYPE,
    GROUP_CONCAT(music_styles.MUSIC_STYLE_NAME) AS MUSIC_STYLE_NAME
FROM events
INNER JOIN venues 
    ON events.VENUE_LOCATION = venues.ID
INNER JOIN party_types
    ON events.PARTY_TYPE = party_types.ID
INNER JOIN events_music_styles
    ON events.ID = events_music_styles.event_id
INNER JOIN music_styles
    ON events_music_styles.music_style_id = music_styles.id
WHERE start_datetime >= '$DATE_START_SELECTED'
AND end_datetime < '$DATE_END_SELECTED' 
GROUP BY events.ID
";



$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){

echo "<tr>";
echo "<td><IMG src='" . $row['IMAGE_URL'] . "' hspace='10px'></td>";
echo "<td><h6>" . $row['VENUE_NAME'] . "</h6>" . $row['EVENT_NAME'] . "</td>";
echo "<td>" . $row['PARTYTYPE'] . "</td>";
echo "<td>" . $row['ENTRANCE_PRICE'] . "</td>";
echo "<td>" . $row['MUSIC_STYLE_NAME'] . "</td>";
echo "<td>" . $row['BEER_PRICE'] . "</td>";
echo "<td>" . $row['WINE_PRICE'] . "</td>";
echo "<td>" . $row['SPIRITS_PRICE'] . "</td>";
echo "</tr>"; 
}

?>

谢谢大家!

1 个答案:

答案 0 :(得分:1)

添加答案休息位于评论中

在这里你会有所帮助:

是的,很酷你是否注意到你的 thead 没有结束标记,你可以试试这个而不是标题和小部件只是想看看会发生什么:$(“#eventsTable”)。的tablesorter();

或此处的示例:jsfiddle.net/6gjLs/4

欢呼声