我需要为学校创建一个数据库。当我在我的专栏“Champion”中悬停一个物体时,我想向用户显示左侧冠军的照片。我想用Jquery做这个。我在网上搜索过,但我找不到答案。这是我的剧本:
Observable.create({
->
// doing background task...
})
.onSubscribe(Schedules.newThread())
.flatMap(() -> getOtherObservable())
.subscribe(() -> {
// onNext...
});
private Observable getOtherObservable(){
// return other Observable
return ...;
}
答案 0 :(得分:0)
首先,我看到你有点困惑。
PHP 是一种server-side
编程语言;这意味着在将页面发送到客户端(浏览器)之前,所有PHP代码都在服务器上呈现。
JQuery 是一个JavaScript
类,旨在简化JavaScript
脚本/编程; JavaScript
是一种client-side
脚本/编程语言,这意味着任何JavaScript/JQuery
代码都在客户端上执行(我们可以说是浏览器)。
好的,现在关于你的问题。如果要在一组单元格/列的鼠标悬停事件中显示图像,可以执行以下操作:
<html>
<head>
<link rel="stylesheet" type="text/css" href="stijl.css">
</head>
<body>
<!-- the following code does not need PHP, so just leave it as HTML -->
<aside id="links">
<p id="Aatrox">
<img src="http://eindwerkstef.be/php/champions/Aatrox.jpg"/>
<p>
</aside>
<form action="php54.php" method="post">
<aside>
<select name="sorteren">
<option value="Champion">Champion</option>
<option value="Role">Role</option>
<option value="Lane">Lane</option>
<option value="Counter">Counter</option>
</select>
<select name="sorteren2">
<option value="Champion">Champion</option>
<option value="Role">Role</option>
<option value="Lane">Lane</option>
<option value="Counter">Counter</option>
</select>
</br>
<input type="submit" name="submit" value="Sorteer!"/>
</br>
<p>Wat wilt u Weergeven?</p>
<select name="toonL">
<option value="Top">Top</option>
<option value="Mid">Mid</option>
<option value="Jungle">Jungle</option>
<option value="Bottom">Bottom</option>
</select>
<input type="submit" name="toon1" value="Toon"/>
</aside>
<?php
$address = "localhost"; // this is your database's address
$username = "root"; // this is your mysql username
$password = "1234"; // this is your mysql password
$database = "example"; // this is your database
$connection = mysqli_connect($address, $username, $password, $database);
if (isset($_POST['submit'])){
$query = "SELECT * FROM lolOverzicht ORDER BY {$_POST['sorteren']}, {$_POST['sorteren2']}";
$res = mysqli_query($connection, $query);
echo("<table border='1' id='tbloverzicht'><tr><td><b>Champion</td><td><b>Role</td><td><b>Lane</td><td><b>Counter</td></tr>");
while ($row = $res->fetch_assoc()){
echo("<tr>");
echo("<td class='col-champion'>".$row['Champion']."</td>
<td>".$row['Role']."</td>
<td>".$row['Lane']."</td>
<td>".$row['Counter']."</td>
<td><a href=\"lolwijzig.php?id={$row['Nummer']}\">Wijzig</a></td>
<td><a href=\"lolverwijder.php?id={$row['Nummer']}\">Verwijder</a>
</td>");
echo("</tr>");
}
echo "</table>";
}
if (isset($_POST['toon1'])){
$query = "SELECT * FROM lolOverzicht WHERE Lane = '{$_POST['toonL']}' ORDER BY {$_POST['sorteren']}, {$_POST['sorteren2']}";
$res = mysqli_query($connection, $query);
echo "<table border='1' id='tbloverzicht'><tr><td><b>Champion</td><td><b>Role</td><td><b>Lane</td><td><b>Counter</td></tr>";
while ($row=mysql_fetch_array($res)){
echo("<tr>");
echo("<td class='col-champion'>".$row['Champion']."</td>
<td>".$row['Role']."</td>
<td>".$row['Lane']."</td>
<td>".$row['Counter']."</td>
<td><a href=\"lolwijzig.php?id={$row['Champion']}\">Wijzig</a></td>
<td><a href=\"lolverwijder.php?id={$row['Champion']}\">Verwijder</a></td>");
echo("</tr>");
}
echo("</table>");
}
mysqli_close($connection);
?>
<img src"" id="img">
<script src="script/jquery-1.11.1.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$('#img').hide();
});
$('.col-champion').mouseover( function(e){
/*
Since I don't know where and how you decide which image to show, that's up to you
then to change img source just use:
$("#img").attr("src","chosenimage.jpg");
*/
$('#img').show();
$("#img").offset({left:e.pageX,top:e.pageY});
});
$('.col-champion').mouseout( function(e){
$('#img').hide();
});
</script>
</body>
注意:我从mysql更改为mysqli,因为现在不推荐使用mysql,我强烈建议您使用mysqli进行下一个项目。
建议:对于未来的问题,我强烈建议您解释问题的每一个细节,提供您认为可以使您的问题更容易理解的所有内容。
然后,如果您需要一些淡入淡出效果,可以点击here
查看JQuery的官方文档。我希望这能帮到你,祝你的功课好运!