/    Sign up×
Community /Pin to ProfileBookmark

Combine javascript + mysql

I want to change the position of a div-element every 3 seconds. The coordinates of the element are saved in the mysql-database. The problem is I only get the last value of the record, so it gets to one position and then never to the second one. Can somebody help me with this problem. (Sorry for my bad english)

[code=php]

echo ‘setInterval(“reset()”,3000);’;

$query = mysql_query(“SELECT * FROM homepage WHERE publiceer = 1”);
while ($row = mysql_fetch_object($query))
{

$query2 = mysql_query(“SELECT * FROM homepage WHERE id = ‘”.$row->id.”‘ LIMIT 1″);
while ($row2 = mysql_fetch_object($query2))
{
echo ‘function reset(){‘;
echo ‘document.getElementById(“slidecaption”).style.top = ‘.$row->positie_y.’ + “px”; document.getElementById(“slidecaption”).style.left = ‘.$row->positie_x.’ + “px”;’;
echo ‘alert(“‘.$row2->id.'”);’;
echo ‘}’;
}

// echo ‘alert(“‘.$row->id.'”);’;

}

[/code]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @zlatan99 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...