<?php
require_once('../conn.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta chaeset="utf-8">
<title>Web</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<header>
<h1><a href="../index.php">Web</a></h1>
</header>
<nav>
<ol>
<?php
$sql = "SELECT * FROM `topic`";
$result = mysqli_query($conn,$sql);
while($row=mysqli_fetch_assoc($result)){
echo '<li><a href="http://localhost/index.php?id='.$row['id'].'">'.htmlspecialchars($row['title']).'</a></li>'."\n";
}
?>
</ol>
</nav>
<article>
<?php
$id=mysqli_real_escape_string($conn,$_GET['id']);
$sql="SELECT * FROM topic WHERE id=".$id;
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($result);
?>
<form class="" action="modify_check.php" method="POST">
<input type="hidden" name="id" id="id" value="<?php echo $id ?>">
<p>
<label for="title">제목 :</label>
<input type="text" name="title" id="title" value="<?php echo $row['title'];?>">
</p>
<p>
<label for="description">본문</label>
<textarea id="description" rows="8" cols="40" name="description" value="<?php echo $row['description'];?>"></textarea>
</p>
<p>
<input type="submit" value="제출">
</p>
</form>
</article>
</body>
</html>
이렇게 해서 id값을 넘기고
<?php
require_once('../conn.php');
$title = mysqli_real_escape_string($conn,$_POST['title']);
$description = mysqli_real_escape_string($conn,$_POST['description']);
$id=mysqli_real_escape_string($conn,$_POST['id']);
$sql = "UPDATE `topic` SET title='$title', description='$description' WHERE id=".$id;</p><p><span class="Apple-tab-span" style="white-space:pre"> mysqli_query($conn,$sql);
header('Location:../index.php');
?>
이 부분에서 mysql 수정테이블인데 글 수정이 안된다.. 미치겠다 뭐가 문제인거지.. 도움좀 주세요 ㅠㅠ
Conn.php랑 알맞은 디렉토리에 위치되어있는지확인하시고. 변수$conn 확인해보시고. Post로넘어온데이터 다 찍어보시고. 제추측으론 지금 conn.php랑 제대로 연결안된거같아염
가독성좀
각 단계별로 error_log 함수 써서 파일에 변수들 쓰게 하고 뻑나는 위치 확인해봐. 정밀 디버깅도 안하고 징징대냐...