- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
<?php
echo count($arr);
$i = count($arr) - 1;
for ($i; $i >= 0; $i--) {
?>
<div class="post" id="p<?php echo $arr[$i]->_id; ?>">
<div class="p_title"><?php echo $arr[$i]->title; ?></div>
<div class="p_content"><?php echo $arr[$i]->content; ?></div>
<div class="p_date"><?php echo $arr[$i]->date; ?></div>
<form id="<?php echo $arr[$i]->_id; ?>" action="index.php" method="get">
<!--<textarea rows="4" cols="50" name="removid" style="display: none;" ><?php echo $arr[$i]->_id; ?></textarea>-->
<input type="text" name="removid" form="<?php echo $arr[$i]->_id; ?>" value="<?php echo $arr[$i]->_id; ?>"/>
<input type="submit" class="p_remove" onclick="dele('<?php echo $arr[$i]->_id; ?>');" form="<?php echo $arr[$i]->_id; ?>" value="Удалить"/>
</form><!--</div>-->
<?php echo $arr[$i]->_id; ?>
</div>
<?php
}
?>
<script>
function dele(param){
var jsVar = "<?php
$removid = $_GET['removid'];
$bulk = new MongoDB\Driver\BulkWrite;
//$bulk->delete(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
$query = new MongoDB\Driver\Query(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
$bulk->delete(['_id'=> new MongoDB\BSON\ObjectId($removid)]);
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);
try {
$result = $manager->executeBulkWrite('forum.posts', $bulk, $writeConcern);
//header('Location: https://benar.wtf/index.php');
}
catch (MongoDB\Driver\Exception\BulkWriteException $e) {
$result = $e->getWriteResult();
}
?>";
}
</script>