使按钮在刷新时移动


Making a button move on refresh

你好,我试图使一个按钮在php中移动,并从j查询家伙寻找提示,以防在j查询中更容易做到。我已经弄清楚了,如果我把左,右,中(单词)放在一个数组中然后随机选择一个并将其打印出来在div标签中然后在div标签中放置一个按钮div应该被安排为右,左,中这将使按钮移动?这是我的代码

<?php
$Keywordarray = new array(3);  
$Keywordarray[0] = "left";  
$Keywordarray[1] = "right";  
$Keywordarray[2] = "center";  
$rand_key = array_rand($Keywordarray);

?>
<div align="<?php echo $rand_key ; ?>">
  <button type="button">Click Me!</button>
</div>

但是我得到一个白页??我想尝试移动按钮来停止宏播放但只能移动左右和中间

我也试过这个

<?php
$numbers = range(left, right , center);
shuffle($numbers);
foreach ($numbers as $number) {
}

?>
<div align="<?php echo $number ; ?>">
  <button type="button">Click Me!</button>
</div>

哪个页面出现但按钮没有移动?

找到一些可以运行的java脚本

<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var flag = 1;
function t() {
if(flag == 1) {
Y.style.top = "75px";
Y.style.left = "700px";
}
if(flag == 2) {
Y.style.top = "115px";
Y.style.left = "100px";
}
if(flag == 3) {
Y.style.top = "300px";
Y.style.left = "350px";
}
flag = flag + 1;
if(flag == 4) {
flag = 1;
}
}
function al() {
alert("Correct!");
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center>
</center>

</DIV>
<DIV ID="Y" STYLE="position:absolute; left:300px; top:300px; width:50px;
height:50px;">
<form>
<input type=button value="YES" onClick="t()">
</form>
</DIV>

try:

$rand_key = $Keywordarray[array_rand($Keywordarray)];

你应该先看看手册:)http://php.net/manual/en/function.array-rand.php