나는 내가 만든 바위 가위 게임을위한 리더 보드를 만들고 있습니다. SQL 테이블에서 데이터를 검색하여 HTML 테이블에 삽입해야합니다. 테이블에서 값을 검색하는 코드가 있지만 CSS 스타일 시트가 아닌 페이지의 왼쪽 위에 인쇄됩니다.PHP와 MYSQL을 사용하여 HTML 테이블을 채울 필요가 있습니다.
<?php
$connect = mysql_connect("localhost","username", "passworkd");
if (!$connect) {
die(mysql_error());
}
mysql_select_db("username");
$results = mysql_query("SELECT * FROM highscore ORDER BY Score");
while($row = mysql_fetch_array($results)){
?>
<tr>
<td><?php echo $row['Name']?></td>
<td><?php echo $row['Score']?></td>
<td><?php echo $row['Date']?></td>
</tr>
}
?>
<?php
<html>
<head>
<link rel="stylesheet" href ="css/table.css">
<title>Leaderboards - Rock, Paper, Scissors</title>
</head>
<body>
<div class="easyTable" >
<table >
<tr>
<td colspan="3"><a style="color: white;"href="TypingTest.html">Typing Test, WPM - Easy<a></td>
</tr>
<tr id="easyTitle">
<td style="color: white;"> <?php echo $row['Name']?>
Name
</td>
<td style="color: white;"><?php echo $row['Score']?>
Score
</td>
<td style="color: white;"><?php echo $row['Date']?>
Date
</td>
</tr>
<tr>
<td >
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td >
Row 2
</td>
<td>
Row 2
</td>
<td>
Row 2
</td>
</tr>
<tr>
<td >
Row 2
</td>
<td>
Row 2
</td>
<td>
Row 2
</td>
</tr>
<tr>
<td >
Row 3
</td>
<td>
Row 3
</td>
<td>
Row 3
</td>
</tr>
<tr>
<td >
Row 2
</td>
<td>
Row 2
</td>
<td>
Row 2
</td>
</tr>
<tr>
<td >
Row 2
</td>
<td>
Row 2
</td>
<td>
Row 2
</td>
</tr>
<tr>
<td >
Row 2
</td>
<td>
Row 2
</td>
<td>
Row 2
</td>
</tr>
<tr>
<td >
Row 2
</td>
<td>
Row 2
</td>
<td>
Row 2
</td>
</tr>
</table>
</div>
당신은 html과 php 사이의 줄을 흐리게하고 있습니다.' php'는 html을 포함하지 않아야합니다. – Ibu
그걸 수정 했는데도 여전히 내 테이블의 행을 채우지 못합니다. – user278153
mysql_ *을 사용하지 마십시오. 사용되지 않습니다. – ThePixelPony