dbcon.php
<?php
$host="localhost";
$user="spring";
$password="1234";
$conn=mysql_connect($host, $user, $password);
mysql_select_db("web");
// if($conn==true){
//
// echo "MARIA DB에 연결 되었습니다.";
// }else{
//
// echo "MARIA DB에 연결 실패 하였습니다.";
// }
//
?>
list.php
<?php
include_once("dbcon.php");
$sql ="select * from guestbook order by idx desc";
$rs =mysql_query($sql);
echo "<a href='write.html'>작성</a>";
echo "<table border='1' >";
echo
"<tr>
<th>번호</th>
<th>이름</th>
<th>내용</th>
<th>이메일</th>
<th>날짜</th>
</tr>
";
while($row = mysql_fetch_array($rs)){
echo "
<tr>
<td>$row[idx]</td>
<td>$row[name] </td>
<td><a href='view.php?idx=$row[idx]'>$row[content]</a></td>
<td>$row[email]</td>
<td>$row[post_date]</td>
</tr>";
}
mysql_close();
?>
view.php
<?php
include_once("dbcon.php");
$query="select * from guestbook where idx=".$_GET["idx"];
$rs=mysql_query($query);
if($row=mysql_fetch_array($rs)){
$name=$row["name"];
$email=$row["email"];
$content=$row["content"];
}
?>
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<h2>방명록 작성</h2>
<form action="alter.php" method="post" name="form1">
<table border="1" width="500px">
<tr>
<td>이름</td>
<td><input type="text" name="name" value="<?php echo $name; ?>"></td>
</tr>
<tr>
<td>이메일</td>
<td><input type="text" name="email" value="<?php echo $email;?>"></td>
</tr>
<tr>
<td>내용</td>
<td><textarea name="content" rows="8" cols="40"><?php echo $content ; ?></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="수정"></td>
</tr>
</table>
</form>
</body>
</html>
댓글 ( 4)
댓글 남기기