有一個惱人的小問題。找不到解決方案的工作嘗試了一切,我可以找到從搜索這裏和谷歌。動態鏈接/ 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。總是渴望學習新的東西 –