안녕하세요, 내 news_id
을 트위터 모달로 전달하고 싶습니다. 하지만 잘못된 데이터를 받고 누군가가 내게 모달로 데이터를 전달하는 방법에 대한 아이디어를 줄 수 있습니까?트위터 모달에 데이터 전달
및 삭제 된 데이터가 news_id와 뉴스 "28"입니다
여기 내 코드입니다.
<div class="container">
<table class="table table-bordered" >
<thead>
<tr>
<th width="60">ID</th>
<th width="200">News Title</th>
<th width="150">Date Posted</th>
<th>Content</th>
<th width="200">Image</th>
<th width="200">Action</th>
</tr>
</thead>
<tbody>
<?php
$stmt = mysqli_prepare($con, "SELECT * FROM news ORDER BY news_id");
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while($row = mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $row['news_id']; ?></td>
<td><?php echo $row['news_title']; ?></td>
<td><?php echo $row['news_date']; ?></td>
<td><?php echo $row['news_content']; ?></td>
<td><img style="height:150px; width:200px;" src="<?php echo $row['news_image']; ?>" ></td>
<td>
<a class='btn btn-info left-margin' href="edit2.php?newsid=<?php echo $row['news_id'];?>" ><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a class='btn btn-danger delete-object' data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-remove"></span> Delete</a>
<div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
Are you sure you want to delete this?
</div>
<div class="modal-footer">
<a class='btn btn-danger left-margin' href="delete.php?newsid=<?php echo $row['news_id'];?>" >Yes</a>
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
여기 내 delete.php
<?php
include_once('connection.php');
$newsid = $_GET['newsid'];
if(isset($newsid)){
$stmt = mysqli_prepare($con, "DELETE FROM news WHERE news_id = ?");
mysqli_stmt_bind_param($stmt, "s", $newsid);
mysqli_stmt_execute($stmt);
header('location: edit.php');
}
?>
맙소사! 당신의 영웅 @ 크리스 senpai : D 조 감사 마스터. – nethken
다행 이네요. –
님? 채팅으로 이동할 수 있습니까? – nethken