有一个恼人的小问题。找不到解决方案的工作尝试了一切,我可以找到从搜索这里和谷歌。动态链接/ javascript的重定向/ php
的目的,这是沿着其传递到先前已创建了一个“房间”。
好像也无所谓什么我尝试,我不能把它加载到使用的onclick带有href另一页。我知道它很容易解决它的一些愚蠢的事情,我想不出来。
和抱歉,如果我没有张贴我的代码恰到好处,这是我第一次问一个问题,我通常只是潜伏在寻找答案。
//..Left out <?php and my connect info but it is in my script
//--CLEANUP MY MESS
$sql = "SHOW TABLES";
$result = mysql_query($sql) or die('err11');
while ($row = mysql_fetch_row($result)) $testing[$row[0]] = true;// Gets a list of tables in the database and turns them into a handy format
if ($testing['prim']){// Checks to see if table prim exists
$sql = "SELECT * FROM prim"; // Pulling all info again after cleaning
$result = mysql_query($sql) or die('err11');
$_e = '';
while ($row = mysql_fetch_assoc($result)){// Cycle through enteries to see what rooms are up
$_e = $_e . "<a href='' onclick='join(" . $row['room'] . ");'>" . $row['teach'] ."</a><br>";
}
}else $_e = "Sorry no rooms are open";
mysql_close($con);
?>
<!DOCTYPE html>
<html>
<head>
<script>
function join(er) {
alert('ffs is this even firing');//this is a debug statement i was using... it was firing
//THE LINE BELOW DOES NOT SEEM TO WORK
document.location = "http://***late edit to get rid of the web address lol sorry***start.php?name=" + document.getElementById("name").value + "&room=" + er;
//THE LINE ABOVE DOES NOT WORK
}
</script>
<title>Portal</title>
</head>
<body>
Name:<input type="text" id='name' name="name"><br><?php echo $_e ?>
</body>
</html>
我试着像window.location的window.location.href等等等等许多不同的小的变化..也搞砸与回报,只是我发疯 感谢所有帮助和你们这些人有一个愉快的一天
** Heads up!** PHP的未来版本是*弃用和删除mysql_'系列函数。现在将是[切换到PDO](http://php.net/book.pdo)或[mysqli](http://php.net/book.mysqli)的好时机。 – Charles
将检查到tyvm。总是渴望学习新的东西 –