Php 悬停时显示数据库的值
我想为我的网站做一个活动日历。在日历上,当鼠标悬停时,我希望在特定日期显示整个事件描述。但我不知道怎么做。我使用jquery和mysqli来悬停和检索数据 这是我当前项目的图像 我有一个数据库,其中包括“事件id、事件标题、事件日期和事件描述” 这就是我从数据库中获取价值的方式Php 悬停时显示数据库的值,php,jquery,hover,Php,Jquery,Hover,我想为我的网站做一个活动日历。在日历上,当鼠标悬停时,我希望在特定日期显示整个事件描述。但我不知道怎么做。我使用jquery和mysqli来悬停和检索数据 这是我当前项目的图像 我有一个数据库,其中包括“事件id、事件标题、事件日期和事件描述” 这就是我从数据库中获取价值的方式 while($r=$q->fetch_assoc()) { $event_id=$r['event_id']; //This is a unique ID from my DB
while($r=$q->fetch_assoc()) {
$event_id=$r['event_id']; //This is a unique ID from my DB
$event_title=$r['event_title']; //Obvious title is obvious
$event_desc=$r['event_desc']; // I want to post this on the popbox at the bottom
echo $event_title."<br />";
<a class='popper' data-popbox='pop2' href='viewEvent?id=$event_id'>See more</a><br />";
echo "<div id='pop2' class='popbox'>";
echo " <h2>Event for today!!</h2>";
echo " This text should have the 'event_description'";
echo "</div>";
while($r=$q->fetch_assoc()){
$event\u id=$r['event\u id'];//这是我的数据库中唯一的id
$event_title=$r['event_title'];//明显的标题是明显的
$event_desc=$r['event_desc'];//我想把它发布在底部的弹出框中
echo$event_title.“
”;
“;
回声“;
回声“今天的活动!!”;
echo“此文本应具有‘事件描述’”;
回声“;
div ID pop2和class popbox是链接悬停时的代码
$(function() {
var moveLeft = 0;
var moveDown = 0;
$('a.popper').hover(function(e) {
var target = '#' + ($(this).attr('data-popbox'));
$(target).show();
moveLeft = $(this).outerWidth();
moveDown = ($(target).outerHeight() / 2);
}, function() {
var target = '#' + ($(this).attr('data-popbox'));
$(target).hide();
});
$('a.popper').mousemove(function(e) {
var target = '#' + ($(this).attr('data-popbox'));
leftD = e.pageX + parseInt(moveLeft);
maxRight = leftD + $(target).outerWidth();
windowLeft = $(window).width() - 40;
windowRight = 0;
maxLeft = e.pageX - (parseInt(moveLeft) + $(target).outerWidth() + 20);
if(maxRight > windowLeft && maxLeft > windowRight)
{
leftD = maxLeft;
}
topD = e.pageY - parseInt(moveDown);
maxBottom = parseInt(e.pageY + parseInt(moveDown) + 20);
windowBottom = parseInt(parseInt($(document).scrollTop()) + parseInt($(window).height()));
maxTop = topD;
windowTop = parseInt($(document).scrollTop());
if(maxBottom > windowBottom)
{
topD = windowBottom - $(target).outerHeight() - 20;
} else if(maxTop < windowTop){
topD = windowTop + 20;
}
$(target).css('top', topD).css('left', leftD);
});
});
$(函数(){
var-moveLeft=0;
var-moveDown=0;
$('a.popper')。悬停(函数(e){
var target='#'+($(this.attr('data-popbox'));
$(target.show();
moveLeft=$(this.outerWidth();
moveDown=($(target.outerHeight()/2);
},函数(){
var target='#'+($(this.attr('data-popbox'));
$(target.hide();
});
$('a.popper').mousemove(函数(e){
var target='#'+($(this.attr('data-popbox'));
leftD=e.pageX+parseInt(moveLeft);
maxRight=leftD+$(目标).outerWidth();
windowLeft=$(window).width()-40;
windowRight=0;
maxLeft=e.pageX-(parseInt(moveLeft)+$(target.outerWidth()+20);
如果(maxRight>windowLeft&&maxLeft>windowRight)
{
leftD=maxLeft;
}
topD=e.pageY-parseInt(向下移动);
maxBottom=parseInt(e.pageY+parseInt(moveDown)+20);
windowBottom=parseInt(parseInt($(document.scrollTop())+parseInt($(window.height());
maxTop=topD;
windowTop=parseInt($(document.scrollTop());
如果(maxBottom>windowBottom)
{
topD=windowBottom-$(目标).outerHeight()-20;
}else if(maxTop
请告诉我您希望看到什么代码来帮助我破解这个螺母。提前谢谢;)您可以按照以下步骤操作 (1) 。您应该有一个如下所示的悬停事件 例如 范例
$( "#pop2" ).load( "getevent.php", { eventid: <?php echo $event_id; ?> }, function() {alert( "done" );});
(2) .现在您需要做的是,使用.load显示数据块
范例
$( "#pop2" ).load( "getevent.php", { eventid: <?php echo $event_id; ?> }, function() {alert( "done" );});
$(“#pop2”).load(“getevent.php”,{eventid:},function(){alert(“done”);});
将eventid作为参数传递给getevent.php
阅读更多
抱歉,我的英语不好。?一种简单的方法是在悬停时调用ajax,并在工具提示中显示检索到的描述,另一种方法是如果事件不太多,则将所有事件存储在javascript数组中,并在悬停时按日期过滤数组。嗨!Joachim,我访问了该站点,并且有一堆工具提示!我想k我的解决方案将是AJAX,对吗?但我对AJAX调用以及与此相关的事情一无所知。嗨,米纳斯!这实际上是我的第一选择!我很想使用数组方法,但我想我必须假设这个数组中将存储大量事件。你认为数组调用可以处理它吗?对于数组方法ach仅在日历中加载当前月份的事件,当日历上的月份发生变化时,您可以调用ajax在Array中加载该月份的事件,并将鼠标悬停在“我的”链接上“但问题是,我无法将数据库中的数据传递到悬停框上的消息中。我已编辑了上述JSFIDLE,请检查。嗯……我现在有悬停,但我添加的加载没有任何作用。我真的很困惑:(是的~!我已经能够在我的两个链接上显示一个内容。我只需要在其他链接上这样做!pop2处于while循环中,只要有一个事件,就会有很多pop2。因此,我需要根据它们的日期显示它们相应的描述!我们很接近了!非常感谢:DAn id在单个文档上只能使用一次.页面上不应存在多个pop2 id。。。