0
예를 들어 '나는 피아노를 치고 싶습니다.'라는 문장이 있습니다. 그것은 4 개의 요소로 분리되어 데이터베이스 (myphpadmin)에서 제거됩니다. 셔플 버튼을 누른 경우에만 어떻게 만들 수 있습니까? 그러면 셔플됩니다.데이터베이스의 onClick 셔플 버튼
<body>
<?php
// Connect to database server
mysql_connect("localhost", "root", "password") or die (mysql_error());
// Select database
mysql_select_db("login") or die(mysql_error());
// Get data from the database depending on the value of the id in the URL
$strSQL = "SELECT * FROM sentences WHERE id
ORDER BY RAND() LIMIT 1;";
//create an array with numbers 1-4
$order = array(1,2,3,4);
//shuffle them in random order
shuffle($order);
$rs = mysql_query($strSQL);
// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {
// Write the data of the person
//Display all the array values from 0-3 (array index starts from 0)
echo "<dt>Sentence:</dt><dd>" . $row[$order[0]] . " " . $row[$order[1]] . " " .
$row[$order[2]] . " " . $row[$order[3]] ."</dd>";
}
// Close the database connection
mysql_close();
?>
<button onClick="Shuffle()">Scramble</button>
</body>
내가 시도했지만 배열이 HTML 페이지에 표시되지 않습니다. 셔플 버튼 만 있습니다. – user3678617
@ user3678617 실제 파일에 연결되는 스크립트를 수정 했습니까? 웹 개발자 도구 콘솔에서 오류가 있는지 확인하십시오. – Darren
오류가 발견되지 않고 스크립트를 수정하여 html 파일에 연결했습니다. 그러나 주인공은 셔플 버튼을 허용하지 않습니다. – user3678617