반환 된 SQL 쿼리를 기반으로 새 테이블을 표시하려고합니다. 이것은 사용자가 페이지를로드 할 때 표시되는 원래 테이블 코드입니다.결과 테이블 표시 SQL
표는 :
<form action="walkthroughs.php" method="POST">
Platform: <input type="text" name="platform"/><br/>
<input type="submit" value="Search"/>
</form>
<body>
<section class="container">
<div class="row">
<table id="table1" class="table table-bordered">
<thead>
<th>ID</th>
<th width="25%">FAQ Title</th>
<th width="25%">Game</th>
<th width="*">Platform</th>
<th width="15%">Date Created</th>
<th width="15%">Date Modified</th>
</thead>
<tbody>
<?php
mysql_connect("localhost", "root", "password") or die(mysql_error()); //Connect to server
mysql_select_db("walkthroughs") or die("Cannot connect to database"); //connect to database
$query = mysql_query("Select * from faqlist"); // SQL Query
while($row = mysql_fetch_array($query))
{
Print "<tr>";
Print '<td align="center">'. $row['FAQ_ID'] . "</td>";
Print '<td align="center">'. $row['FAQ_Title'] . "</td>";
Print '<td align="center">'. $row['Game'] . "</td>";
Print '<td align="center">'. $row['Platforms'] . "</td>";
Print '<td align="center">'. $row['Date_Created'] . "</td>";
Print '<td align="center">'. $row['Date_Modified'] . "</td>";
Print "</tr>";
}
?>
</tbody>
</table>
</div>
</section>
</body>
이것은 내가 실행하기 위해 노력하고있어 PHP 코드입니다. (내 </html>
태그의 바닥에 배치.)
PHP : 내가 다른 테이블을 추가하고 을 숨기지 않고 ID "표"와 HTML 테이블을 업데이트하려면 어떻게
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") // Added an if to keep the page secured
{
$platform = mysql_real_escape_string($_POST['platform']);
mysql_connect("localhost", "root", "password") or die(mysql_error()); // Connect to server
mysql_select_db("walkthroughs") or die("Cannot connect to database"); // Connect to database
$query = mysql_query("SELECT FAQ_ID, FAQ_Title, Game, Platforms FROM faqlist WHERE
Platforms LIKE '$platform' OR Platforms LIKE '%$platform' OR Platforms LIKE '$platform%' OR Platforms LIKE '%$platform%'"); // SQL Query
while($row = mysql_fetch_array($query))
{
Print "<tr>";
Print '<td align="center">'. $row['FAQ_ID'] . "</td>";
Print '<td align="center">'. $row['FAQ_Title'] . "</td>";
Print '<td align="center">'. $row['Game'] . "</td>";
Print '<td align="center">'. $row['Platforms'] . "</td>";
Print "</tr>";
}
}
else
{
header("location: walkthroughs.php");
}
?>
" table1 " 테이블? 나는 현재 PHP로 시작하고있다.
때마다 [은'mysql_'] (http://stackoverflow.com/questions/12859942/why-shouldnt- i-use-mysql-functions-in-php) 새 코드 데이터베이스 확장 ** [새끼 고양이는 세계 어딘가에서 교살 된 상태입니다.] (http://2bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg /AS6XCd6aNdg/s1600/luna_getting_strangled.jpg) * 그것은 더 이상 사용되지 않으며 수년간 계속되었으며 PHP7에서 영원히 사라졌습니다. PHP를 배우려는 분이라면'PDO' 또는'mysqli' 데이터베이스 확장과 prepared statement를 배우는 데 많은 시간을 할애하십시오. [여기에서 시작] (http://php.net/manual/en/book.pdo.php) – RiggsFolly
스크립트에 [SQL 주입 공격] 위험이 있습니다 (http://stackoverflow.com/questions/60174/how -in-prevent-sql-injection-in-php) [Little Bobby Tables] (http://bobby-tables.com/)에 무슨 일이 있었는지 살펴 보자. [입력을 이스케이프하고 있다면 안전하지!] (http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) [준비된 매개 변수가있는 문] (http://php.net /manual/en/mysqli.quickstart.preparedstatements.php) – RiggsFolly
첫 번째 쿼리가 처리 된 후 코드 명을 '' – RiggsFolly