Jump to content
mark0

Onmouseover care sa scoata valoarea unui row din database

Recommended Posts

Posted

Acesta este codul(tot) din fisierul PHP

 <?php
if (isset($_POST['highscore'])) {
$level = $_POST['highscore'];
$user = mysql_query("select * from users order by level desc limit $level");
} else {
$user = mysql_query("select * from users order by level desc limit 50");
}
if (mysql_num_rows($user) == 0) {
echo '<div class="title_box">
<div class="title_inner">
No players. </div>
</div>
';
} else {
echo '
<div id="highscore_range">
<form action="highscore.php" method="POST" accept-charset="utf-8"> <select class="input" name="highscore" size="1" onchange="submit()" >
<option value="50" selected="selected">1-50 <option value="1000">All </select>
</form>
</div>
<div class="title_box" style="margin:0px;">
<div class="title_inner" style="padding: 0px;">
<div id="highscore_table">
<table cellpadding="0" cellspacing="0">
<tr>
<th>Position</th>
<th>Name</th>
<th>Alliance</th>
<th>Level</th>
<th>Honour</th>
<th>Fame</th>
<th>Wins</th>
<th>Losses</th>
<th>Gold</th>
</tr>
';
$i = 0;
while ($g = mysql_fetch_array($user)) {
$numero5 = $g['gold'];

$colour = '#8fff';
if ($g['username'] == $user['username']) {
$colour = 'blue';
}
if ($user['guild'] == 1) {
if ($g['guild'] == 1) {
if ($g['guild_name'] == $name['guild_name'] && $g['username'] != $name['username']) {
$colour = 'green';
} elseif ($g['guild_name'] != $name['guild_name'] && $g['username'] != $name['username']) {
$colour = '#8fff';
}
}
}
echo "
<tr class='alt'>
<th>" . ++$i . "</th>
<td><div><a href='playerprofile.php?id=" . $g['username'] . "' style='color:" . $colour . ";'>" . $g['username'] . "</a>";
if ($g['rank'] == 2) {
echo " <img src='img/vips.png' onMouseOver=\"return escape('<table cellspacing=2 cellpadding=2 valign=middle class=\'tooltipBox\'><tr><td style=\'color:white; font-weight: bold; font-size:9pt\' colspan=\'2\' nowrap=\'nowrap\'>VIP</td></tr></table>')\"> </div></td>";
} elseif ($g['rank'] > 2) {
echo " <img src='img/admin.png' onMouseOver=\"return escape('<table cellspacing=2 cellpadding=2 valign=middle class=\'tooltipBox\'><tr><td style=\'color:white; font-weight: bold; font-size:9pt\' colspan=\'2\' nowrap=\'nowrap\'>Admin</td></tr></table>')\"> </div></td>";
}
echo "
<td><a href='guildprofile.php?id=" . $g['guild_name'] . "' style='color:#8fff;'>" . $g['guild_name'] . "</a></td>
<td>" . number_format($g['level'], 0, ".", ".") . "</td>
<td>" . number_format($g['honour'], 0, ".", ".") . "</td>
<td>" . number_format($g['fame'], 0, ".", ".") . "</td>
<td>" . number_format($g['wins'], 0, ".", ".") . "</td>
<td>" . number_format($g['loses'], 0, ".", ".") . "</td>
<td>" . number_format($numero5, 0, ".", ".") . "</td>
</tr>
";
}
echo "</table> </div>
</div>
</div>";
}
?>

Linia pe care vreau s-o modific:

<td><div><a href='playerprofile.php?id=".$g['username']."' style='color:".$colour.";'>".$g['username']."</a>" ;

M-am gandit la ceva de genul:

 onMouseOver="return escape('<table cellspacing=2 cellpadding=2 valign=middle class=\'tooltipBox\'><tr><td style=\'color:white; font-weight: bold; font-size:9pt\' colspan=\'2\' nowrap=\'nowrap\'>". $g['title'] ."</td></tr></table>')\"> </div></td>";  

doar ca n-am idee cum sa o pun peste

 <td><div><a href='playerprofile.php?id=" . $g['username'] . "' style='color:" . $colour . ";'>" . $g['username'] . "</a>";  

Am mai postat la ajutor aprox acum o saptamana ,n-am primit nici un raspuns care sa ma ajute asa ca am decis sa postez la webdeveloping ,poate am noroc.

Scopul meu e sa fac un sistem de achievements(titluri) care sa apara cand cursorul trece peste numele unuia care este afisat in highscore.

Posted (edited)

Am mai postat la ajutor aprox acum o saptamana ,n-am primit nici un raspuns care sa ma ajute asa ca am decis sa postez la webdeveloping ,poate am noroc.

N-are nicio relevanta in ce categorie postezi pentru ca, majoritatea, Vizualizaeaza topic-urile de la "New Posts", iar eu nici o data nu atrag atentie in ce categorie a fost postat topicul.

Problema ta poate fi rezolvata foarte usor cu ceva de genul

Poti si cu javascript: document.getElementById(\'to_display_'.$row['id'].'\').style.display = \'block\'

Dar mai elegant incluzi jquery si faci asa.


while($row = mysql_fetch_assoc($query)) {
echo '<a href="#" onmouseover="$(\'#to_display_'.$row['id'].'\').show();">'.$row['username'].'</a>';
echo '<div id="to_display_'.$row['id'].'" style="display: none;">Informatia de care ai nevoie sa apara la onmouseover</div>';
}

Edited by GarryOne
Posted

Ideea lui Garry e simpla.

Scoti deja valoarea din row, dar ii dai sa nu fie vizibila (display: none). Apoi faci o functie javascript gen:


document.getElementById("id").onmouseover = document.getElementById("id").style.display = "block";
document.getElementById("id").onmouseout = document.getElementById("id").style.display = "none";

unde id reprezinta id-ul div-ului sau al span-ului unde ai valoarea.

Daca nu te descurci, te pot ajuta contra-cost.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...