Jump to content

Load dynamic data


EDYYY

Recommended Posts

Hello. If someone can help me, i'll be grateful :shy:

So i have a foreach and an $output .= function that fills some infos in a table. Inside it i have a div for each line that when hovering your mouse should get some data .. Here i have a big problem, because for each line it should get some data and i don't know how to do it ...

 

i'll post here some of my code for better understanding.

 

//some java here

<?php

require "class.php";

 

  $server_list = query_group();

  $misc  = server_misc($server);

 

foreach ($server_list as $server)

    {

      $misc  = server_misc($server);

      $server = server_html($server);

      $idi = "{$server['o']['id']}";

$harta = "<a onmouseover=\"ShowContent('harta'); return true;\" onmouseout=\"HideContent('harta'); return true;\" href='".link($server['o']['id'])."' target=\"_self\">{$server['s']['map']}</a>

<div style=\"position:absolute;\" id=\"harta\" class=\"FAQ\">file_get_contents('http://mysite/player.php?d={$idi}')</div> ";

 

$output .= "

<table>

........... some code.....

<td>

{$harta}

        </td>

.......

 

so basicly when i hover my mouse over each row it should get data from the file for that id... The problem is that only one page can be loaded with file_get_contents. I read over the internet that some ajax functions can do it but i really don't know how.

Please help me, i've been looking for 3 days already without any luck  :'(

Link to comment
Share on other sites

thanks for your advice :)

I googled it but with no results. I found some tutorials that works for one page(link) but now in my case here. I should say that i'm no coder, some stuff are are foreign language for me ..

Can you please point me in the right direction ?

By the way, excuse me for not "speaking" correctly.

 

Link to comment
Share on other sites

i didn't understand a bit from there, but i managed to get the data. now, as a final push : how to make it to open in new box (onmouseover and onmouseout). I've seen something but i don't know how to connect what i have with what i should have ..

here is my script:

 

<script type="text/javascript" language="JavaScript">

<!-- Copyright 2006 Bontrager Connection, LLC

var cX = 0; var cY = 0;

function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}

function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}

if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }

else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d) {

d.style.left = (cX+10) + "px";

d.style.top = (cY+10) + "px";

}

function HideContent(d) {

if(d.length < 1) { return; }

document.getElementById(d).style.display = "none";

}

function ShowContent(d) {

if(d.length < 1) { return; }

var dd = document.getElementById(d);

AssignPosition(dd);

dd.style.display = "block";

}

function ReverseContentDisplay(d) {

if(d.length < 1) { return; }

var dd = document.getElementById(d);

AssignPosition(dd);

if(dd.style.display == "none") { dd.style.display = "block"; }

else { dd.style.display = "none"; }

}

//-->

 

$(function() {

 

$(".info").hover(function()

{

 

var id = $(this).attr("id");

var name = $(this).attr("name");

var dataString = 'd='+ id ;

var parent = $(this);

 

 

if(name=='down')

{

 

$(this).fadeIn(200).html('<img src="loader.gif" align="absmiddle">');

$.ajax({

  type: "POST",

  url: "player.php" + "?d=" + id ,

  data: dataString,

  cache: false,

 

  success: function(html)

  {

    parent.html(html);

 

  }  });

 

}

return false;

});

 

});

</script>

 

Also as you see here i already have a function that shows something on mouseover ..

 

$playeri = "<a onmouseover=\"ShowContent('UNIQUEID'); return true;\" onmouseout=\"HideContent('UNIQUEID'); return true;\" href='".link($server['o']['id'])."' target=\"_self\">{$server['s']['playersmax']}</a>

<div style=\"position:absolute;\" id=\"UNIQUEID\" class=\"FAQ\">Player</div> ";

 

$harta = "<a href='' class='info' id={$server['o']['id']} name='down'>{$server['s']['map']}</a>";

 

So how can i make it to show in a "pop-up", div, table or whatever it's called so you can understand me  :confused: I showed you the other function just to see that i already have one for mouseover function, maybe can be modified but it should not mess with the other content it displays..

 

ps: Thanks a lot for youre help !

Later edit: maybe if i can PM you the link, you can see better what i'm talking about ?

Link to comment
Share on other sites

This is why I suggested a framework like JQuery.  It makes everything easier, especially loading into dialogs.  Here is an example:

 

In your .js file, write a function like this:

function newDialog(url) {
$("body").append("");
$("#new-dialog").load(url, {},
		function(responseText, textStatus, XMLHttpRequest) {
		}).dialog( {
	height: 680,
	width: 840,
	draggable :true,
	resizable :false,
	closeOnEscape: false,
	close : function(ev, ui) {
                   $('#new-dialog').remove();
	}
});
}

This creates a div (#new-dialog) on the fly so you have something to populate into.  The "url" parameter is the URL for the AJAX call.  After it makes the call, the responseText will populate into the #new-dialog dialog.  You call it the same way you're doing it now.

 

 

Link to comment
Share on other sites

oh ... i'm uploading the whole php so you can see better, i don't even understand how to call it  :-[

Just treat me like i'm dumb, please. I cannot comprehend anymore any of this ...  :-[

 

link HERE

Please don't upload the entire code, that has nothing to do with it plus people aren't going to download random files.

 

I showed you exactly how to load an AJAX response into a dialog.  You call it like this:

Show Dialog

 

Of course replace google.com with your server call.  Also make sure you include your dialog.js (the file containing "newDialog()") .

Link to comment
Share on other sites

actualy i've tried with onclick and the bugs still are there ...

 

<td title='{$server['s']['name']}' style='text-align:left'>
	   <p onclick=\"newDialog('detaills.php?s={$server['o']['id']}')\">{$misc['name_filtered']}}</p>

        </td>

i hope this is what you asked..

if you click slowly on one row, it openes the dialog, then click another row, it openes .. but if you click fast let's say one click / second on different rows, then the problem appears.

with onmouseover is the same, the problem is that i don't know what function to call on onmouseout=close(event) or something like this ...

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.