I am using a form with radio buttons to post a value to PHP. However, the value is not being sent. This is my code:
HTML:
<form action="voteupdate.php" id="form-id" method="post"onclick="document.getElementById(\'form-id\').submit();">
<input type="hidden" name="type" id="type" value="' . $type . '">
<input type="hidden" name="id" id="id" value="' . $id . '">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default '.$vup.'">
<input type="radio" name="vote" id="1" value="1">
<span class="glyphicon glyphicon-chevron-up"></span> Vote up
</label>
<label class="btn btn-default '.$vd.'">
<input type="radio" name="vote" id="2" value="2">
<span class="glyphicon glyphicon-chevron-down"></span> Vote down
</label>
</div>
</form>
PHP:
<?php session_start();
include('config.php');
$type = $_POST['type'];
$id = $_POST['id'];
echo $_POST['vote'];
if ($type == "images"){
$tid = "imgid";
}
if ($type == "pages"){
$tid = "pageid";
}
if ($type == "posts"){
$tid = "postid";
}
$table = str_replace(""," ",$type);
$table = str_replace('"'," ",$table);
$table = str_replace("'"," ",$table);
$stmt= $pdo->prepare("SELECT * FROM '".$table."' WHERE ".$tid." = :imgid");
$stmt->execute(array(':imgid' => $id));
$stmt = $stmt->fetch();
$vreg = explode(",", $stmt['votereg']);
foreach ($vreg as $v) {
$temp = explode("-", $v);
if ($_SESSION['uid'] == $temp['0']){
if (1 == $temp['1']){
header( 'Location: votesys.php' ) ;
}
else
{
$instruction = "update-exists";
}
}
}
echo $instruction;
?>
<form action="voteupdate.php" id="form-id" method="post"onclick="document.getElementById(\'form-id\').submit();">
is missing a space between method and onclick attributes:
<form action="voteupdate.php" id="form-id" method="post" onclick="document.getElementById(\'form-id\').submit();">
Related
how can i submit a pre checked checkbox on submit?
right now i have
$checked= 'checked="checked"';
<input type="checkbox" name="entity_id['.$row['entity_id'].']" value="Yes" '.$checked.'>
on submit, this is not getting posted, only when checked/unchecked by hand.
my $checked is actually coming from a for-each mysql query.
any help is appreciated.
UPDATE
<form method="post">';
if($hass_lights == 'Yes'){$user->getLights($userid);}
exit('
<br><b>Google is requiring access to your basic profile information.</b><br><br>
<input type="submit" class="btn btn-text" style="height:40px; width:100px" name="authorized" value="Allow" /> <input type="submit" class="btn btn-text" style="height:40px; width:100px" name="authorized" value="Deny" />
</form>
');
function getLights($userID){
$stmt = $this->db->prepare("SELECT * FROM hass_entities WHERE id = :id AND devicetype= 'light' ORDER BY friendly_name ASC");
$stmt->bindParam(':id',$userID);
$stmt->execute();
$userData = $stmt->fetchAll();
echo '
<div class="container">
<button type="button" class="btn btn-info" data-toggle="collapse" style="width:120px" data-target="#lights">Lights</button>
<br/><div id="lights" class="collapse"><br/><table border=0>';
foreach( $userData as $row ) {
if($row['enabled'] == 'Yes'){
$checked = 'checked="checked"';
}else{
$checked = '';
}
echo '<tr><td><label id="'.$row['entity_id'].'">'.$row['friendly_name'].' </label></td><td><input type="checkbox" name="entity_id['.$row['entity_id'].']" value="Yes" '.$checked.'></td></tr>';
}
echo '</table></div></div><br/>';
}
-Dennis
Try this:
<input type="checkbox" name="entity_id['.$row['entity_id'].']" value="Yes" checked>
Your input field is been written in an echo statement? Would be good to see the entire form, but here is your code working:
<form method=POST>
<?php
var_dump($_POST);
$row = [];
$row['entity_id'] = 1;
$checked= 'checked="checked"';
echo '<input type="checkbox" name="entity_id['.$row['entity_id'].']" value="Yes" '.$checked.'>';
?>
<button type="submit">submit</button>
</form>
code:
<?php
$id = $_GET['id'];
$sql = "select * from admin_menu where id = '$id'";
$result = mysqli_query($link,$sql);
while ($row = mysqli_fetch_array($result))
{
$menu_name = $row['menu_name'];
$menu_link = $row['menu_link'];
$priority = $row['priority'];
$admin_id = explode(",", $row['admin_id']);
}
if(isset($_POST['update']))
{
$admin_id = $_POST['admin_id'];
$chk="";
foreach($admin_id as $chk1)
{
$chk .= $chk1.",";
}
$menu_name = $_POST['menu_name'];
$menu_link = $_POST['menu_link'];
$priority = $_POST['priority'];
$sql = "update admin_menu set menu_name = '$menu_name', menu_link = '$menu_link', priority = '$priority', admin_id = '$chk' where id = '$id'";
$result = mysqli_query($link,$sql);
if($result == true)
{
$msg .= "<h3 style='color:green;'>update</h3>";
}
else
{
$msg .= "<h3 style='color:red;'>Error!</h3>";
}
}
?>
<form name="myform" method="post" >
<div class="row">
<label for="Producer_firstname">Admin Name</label>
<?php
foreach ($admin_id as $admin_id)
{
$chk = "";
if (in_array($chk, $admin_id))
{
$chk = 'checked="checked" ';
}
echo '<input type="checkbox" name="admin_id[]" value="'.$admin_id.'" '.$chk.'/><br/>';
}
?>
</div>
<div class="row">
<label for="Producer_firstname">Menu Name </label>
<input size="60" maxlength="255" name="menu_name" id="menu_name" value="<?php echo $menu_name; ?>" type="text" />
</div>
<div class="row">
<label for="Producer_lastname" >Menu Link </label>
<input size="60" maxlength="255" name="menu_link" id="menu_link" type="text" value="<?php echo $menu_link; ?>" />
</div>
<div class="row">
<label for="Producer_lastname" >Priority</label>
<select name="priority" id="priority">
<option value="<?php echo $priority; ?>"><?php echo $priority; ?></option>
<option value="">choose any one</option>
<option value="1">1</option>
<option value="0">0</option>
</select>
</div>
<div class="row buttons">
<button type="submit" name='update' id='update'>update Menu</button>
</div>
</form>
In this code I am fetching multiple checkbox value from table admin2 and I want when I update form value checkbox check if the value of checkbox is exist into database. How can I fix it ?
Thank You
Your code has few issues,
1. Update should be done before select query
2. List of admin not managed separately
3. Priority radio buttons not managed properly
Additional Suggestions,
1. Use prepare query statements
2. use implode for appending multiple values instead of foreach
3. print admin names before checkboxes
<?php
$id = $_GET['id'];
if(isset($_POST['update']))
{
$chk = implode(',', $_POST['admin_id']);
$menu_name = $_POST['menu_name'];
$menu_link = $_POST['menu_link'];
$priority = $_POST['priority'];
$sql = "update admin_menu set menu_name = '$menu_name', menu_link = '$menu_link', priority = '$priority', admin_id = '$chk' where id = '$id'";
$result = mysqli_query($link,$sql);
$msg = "";
if($result == true)
{
$msg .= "<h3 style='color:green;'>update</h3>";
}
else
{
$msg .= "<h3 style='color:red;'>Error!</h3>";
}
echo $msg;
}
$sql = "select * from admin_menu where id = '$id'";
$result = mysqli_query($link,$sql);
$row = mysqli_fetch_array($result);
$menu_name = $row['menu_name'];
$menu_link = $row['menu_link'];
$priority = $row['priority'];
$admin_id = explode(",", $row['admin_id']);
$admins = array('admin1', 'admin2', 'admin3', 'admin4', 'admin5', 'admin6', 'admin7', 'admin8');
?>
<form name="myform" method="post" >
<div class="row">
<label for="Producer_firstname">Admin Name</label>
<?php
foreach ($admins as $admin)
{
$chk = "";
if (in_array($admin, $admin_id))
{
$chk = 'checked="checked" ';
}
echo $admin.' <input type="checkbox" name="admin_id[]" value="'.$admin.'" '.$chk.'/><br/>';
}
?>
</div>
<div class="row">
<label for="Producer_firstname">Menu Name </label>
<input size="60" maxlength="255" name="menu_name" id="menu_name" value="<?php echo $menu_name; ?>" type="text" />
</div>
<div class="row">
<label for="Producer_lastname" >Menu Link </label>
<input size="60" maxlength="255" name="menu_link" id="menu_link" type="text" value="<?php echo $menu_link; ?>" />
</div>
<div class="row">
<label for="Producer_lastname" >Priority</label>
<select name="priority" id="priority">
<option value="1" <?php if($priority == 1) echo "selected='selected'"; ?>>1</option>
<option value="0" <?php if($priority == 0) echo "selected='selected'"; ?>>0</option>
</select>
</div>
<div class="row buttons">
<button type="submit" name='update' id='update'>update Menu</button>
</div>
</form>
I am trying to get the selected radio button's value. These values are fetched from a MySQL database bound to the controls. When the program executes, it returns null when I check the selected radio buttons value.
Help is highly appreciated. Thanks in advance.
Snippets of my file are as follows:
HTML:
<form method="POST" action="">
<h3><?php echo $_SESSION['Question'] ?></h3>
<input type="radio" name="radio" value="<?php $_SESSION['Option1'] ?>"><?php echo $_SESSION['Option1'] ?><br/>
<input type="radio" name="radio" value="<?php $_SESSION['Option2'] ?>"><?php echo $_SESSION['Option2'] ?><br/>
<input type="radio" name="radio" value="<?php $_SESSION['Option3'] ?>"><?php echo $_SESSION['Option3'] ?><br/>
<input type="radio" name="radio" value="<?php $_SESSION['Option4'] ?>"><?php echo $_SESSION['Option4'] ?><br/>
</div>
</div>
<div class="row">
<input type="submit" class="btn btn-success" name="button_start" value="Start"/>
<input type="submit" class="btn btn-success" name="button_Back" value="Back"/>
<input type="submit" class="btn btn-success" name="button_save" value="Save"/>
<input type="submit" class="btn btn-success" name="button_Next" value="Next"/>
<input type="submit" class="btn btn-danger" name="button_Submit" value="Submit"/>
</div>
</form>
PHP:
function Save($question_id)
{
if (isset($_POST['button_save'])) {
if (isset($_POST['radio'])) {
$selectedValue = $_POST['radio'];
if (is_null($selectedValue) || $selectedValue == "") {
echo "Please select an option";
} else {
$connectionString = mysqli_connect("localhost", "root", "", "knowellaptitudetest");
if (!$connectionString) {
echo "Error unable to connect to MySQL" . PHP_EOL;
echo "Debugging error no." . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error" . mysqli_connect_error() . PHP_EOL;
exit;
}
if ($selectedValue == $_SESSION['Correct_Answer']) {
//save and update marks for correct ans
$marks = 1;
$query = "INSERT INTO section_marks VALUES('" . $question_id . "','" . $marks . "')";
$result = mysqli_query($connectionString, $query);
$row = mysqli_fetch_row($result, MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
} else {
//save and update marks for wrong answer
$marks = -1;
$query = "INSERT INTO section_marks VALUES('" . $row['Question_ID'] . "','" . $marks . "')";
$result = mysqli_query($connectionString, $query);
$row = mysqli_fetch_row($result, MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
}
mysqli_close($connectionString);
}
}
You have to echo the php variable in html.
<input type="radio" name="radio" value="<?php echo $_SESSION['Option1'] ?>"><?php echo $_SESSION['Option1'] ?><br/>
I'm try to send the value from the value attribute in button using a form that use the method POST in "landlord_home.php". The problem was that when I click on the button to go to the next page which is "edit_post.php", it execute the php validation code in that page and display the validation error in that page.
How can I pass the value to "edit_post.php" without using a form(POST or GET method) or is there any other way?
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
echo '<tr>
<td>' . $row['property_id'] . '</td>
<td>' . $row['username']. '</td>
<td>' . $row['property_type']. '</td>
<td>RM' . $row['property_price']. '</td>
<td>' . $row['address']. '</td>
<td>' . $row['location']. '</td>
<td>
<img src="data:property_type;base64,' .
$row['property_picture'] .
'" class="img-thumbnail" width="100" height="100">
</td>
<td>' . $row['title'] . '</td>
<td>' . $row['description'] . '</td>
<td>' . date('F d, Y h:mA', strtotime($row['reg_date'])) . '</td>
<td>
<form action="edit_post.php" method="POST">
<button class="btn btn-success btn-sm" name="edit" value="' .
$row['property_id'] . '">
Edit
</button>
<br>
<button class="btn btn-danger btn-sm" name="delete"
value="'.$row['property_id'] . '">
Delete
</button>
</form>
</td>
</tr>';
}
echo '</table>';
Above is the code from "landlord_home.php". Below is the part of code that I am talking about from above code.
<form action="edit_post.php" method="POST">
<button class="btn btn-success btn-sm" name="edit" value="' .
$row['property_id'] . '">
Edit
</button>
<br>
<button class="btn btn-danger btn-sm" name="delete" value="' .
$row['property_id'] . '">
Delete
</button>
</form>
And below is the code of the next page "edit_post.php"
session_start();
$user = $_SESSION['username'];
if(!isset($_SESSION['username'])) {
require('login_tools_landlord.php');
load();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Edit Property</title>
<link rel="stylesheet" href="css/add_property.css">
<link rel="stylesheet" href="css/header.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
</head>
<body>
<?php include 'includes/header_landlord.php' ?>
<div class="container wrapper">
<div class="text-center title_bar">
<h3>Fill in your property details</h3>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
require ('core/connect_db.php');
$errors = array();
if (isset($_POST['edit'])) {
$edit = $_POST['edit'];
$q = "SELECT * FROM property WHERE property_id = '$edit'";
$r = mysqli_query($dbc, $q);
$row = mysqli_fetch_array($r, MYSQLI_ASSOC);
$prop_type = $row['property_type'];
$price = $row['property_price'];
$address = $row['address'];
$location = $row['location'];
$pic = $row['property_picture'];
$title = $row['title'];
$desc = $row['description'];
$dt = $row['reg_date'];
if (empty($_POST['property_type'])) {
$errors[] = 'Choose property type.';
} else {
$pr = mysqli_real_escape_string($dbc, trim($_POST['property_type']));
}
if (empty($_POST['price'])) {
$errors[] = 'Enter your property price.';
} else {
$p = mysqli_real_escape_string($dbc, trim($_POST['price']));
}
if (empty($_POST['address'])) {
$errors[] = 'Enter your address.';
} else {
$ad = mysqli_real_escape_string($dbc, trim($_POST['address']));
}
if (empty($_POST['location'])) {
$errors[] = 'Choose your location.';
} else {
$lo = mysqli_real_escape_string($dbc, trim($_POST['location']));
}
// if (empty($_POST['picture'])) {
// $errors[] = 'Pick a picture.';
// } else {
// $pc = mysqli_real_escape_string($dbc, trim($_POST['picture']));
// }
if (isset($_POST['submit'])) {
if (getimagesize($_FILES['picture']['tmp_name']) == FALSE) {
$errors[] = "Please select an image.";
} else {
$picture = addslashes($_FILES['picture']['tmp_name']);
$name = addslashes($_FILES['picture']['name']);
$picture = file_get_contents($picture);
$picture = base64_encode($picture);
}
}
if (empty($_POST['title'])) {
$errors[] = 'Enter your title.';
} else {
$ti = mysqli_real_escape_string($dbc, trim($_POST['title']));
}
if (empty($_POST['description'])) {
$errors[] = 'Enter your description.';
} else {
$de = mysqli_real_escape_string($dbc, trim($_POST['description']));
}
if (empty($errors)) {
$qa = "
UPDATE property
SET property_type = '$pr', property_price = '$p', address = '$ad',
location = '$lo', property_picture = '$picture', title = '$ti',
description = '$de', reg_date = NOW()
WHERE property_type = '$prop_type', property_price = '$price',
address = '$address', location = '$location',
property_picture = '$pic', title = '$title',
description = '$desc', reg_date = '$dt'
";
$ra = mysqli_query($dbc, $qa);
if ($ra) {
echo '<h1 class="sccs_msg">Successful</h1>
<p class="sccs_msg">REDIRECTING YOU TO DASHBOARD in 3 SECOND</p>
<meta http-equiv="refresh" content="3;URL=landlord_home.php" />';
}
mysqli_close($dbc);
exit();
} else {
echo '<h1 class="err_msg">ERROR!</h1>
<p class="err_msg">The following error(s) occurred:<br>';
foreach ($errors as $msg) {
echo "- $msg<br>";
}
echo 'Please try again.</p>';
mysqli_close($dbc);
}
}
}
?>
</div>
<form method="post" action="edit_post.php" enctype="multipart/form-data">
<div class="form-group">
<label for="property_type">Property Type</label>
<select class="form-control" name="property_type" id="property_type"
value="<?php
if (isset($_POST['property_type'])) {
echo $_POST['property_type'];
}
?>">
<option></option>
<option>Room</option>
<option>Whole Unit</option>
</select>
</div>
<div class="form-group">
<label for="price">Unit Price(RM)</label>
<input type="text" class="form-control" name="price" id="unit_price"
placeholder="Unit Price" value="<?php
if (isset($_POST['price'])) {
echo $_POST['price'];
}
?>">
</div>
<div class="form-group">
<label for="address">Address</label>
<textarea class="form-control" name="address" id="address" rows="3"
value="<?php
if (isset($_POST['address'])) {
echo $_POST['address'];
}
?>"></textarea>
</div>
<div class="form-group">
<label for="location">Location</label>
<select class="form-control" name="location" id="location"
value="<?php
if (isset($_POST['location'])) {
echo $_POST['location'];
}
?>">
<optgroup label="Kuala Lumpur">
<option></option>
<option>Puchong</option>
<option>Salak Selatan</option>
<option>Segambut</option>
<option>Sentul</option>
<option>Seputih</option>
</optgroup>
<optgroup label="Selangor">
<option>Cheras</option>
<option>Damansara</option>
<option>Cyberjaya</option>
<option>Kajang</option>
<option>Kelana Jaya</option>
</optgroup>
</select>
</div>
<div class="form-group">
<label for="picture">Picture</label>
<input type="file" class="form-control-file" name="picture"
id="picture" aria-describedby="fileHelp"
value="<?php
if (isset($_POST['picture'])) {
echo $_POST['picture'];
}
?>">
<small id="fileHelp" class="form-text text-muted">
Please provide a photo of your property.
</small>
</div>
<div class="form-group">
<label for="title">Title</label>
<input type="text" class="form-control" name="title" id="title"
placeholder="Post Title" value="<?php
if (isset($_POST['title'])) {
echo $_POST['title'];
}
?>">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" name="description" id="description"
rows="3" value="<?php
if (isset($_POST['description'])) {
echo $_POST['description'];
}
?>"></textarea>
</div>
<button type="submit" class="btn btn-primary" name="submit">
Submit
</button>
</form>
</div>
</body>
</html>
How can I pass the value to "edit_post.php" without using a form(POST or GET method) or is there any other way?
I'm not sure to understand what you mean above, unless you wanted to say without using an additional visible form input.
If so, then the answer is contained in the question: you have merely to add a hidden input to your form (and give up buttons value):
<form action="edit_post.php" method="POST">
<input type="hidden" name="property-id" value=" . $row['property_id'] . '">
<button class="btn btn-success btn-sm" name="edit">
Edit
</button>
<br>
<button class="btn btn-danger btn-sm" name="delete">
Delete
</button>
</form>
Then in edit_post.php you can use $_POST['property-id'] as you want.
BTW I'm a bit surprised looking at your $qa query in edit_post.php: unless I missed something subtle, its WHERE clause is invalid, since it's built like a comma-separated list of condition (while they probably should be ANDed).
I can not understand why the application delete the las upload.I am new in php and I hope to help me. Thank you.
Code: HTML
<div class="row">
<div class="col-md-6 col-centered">
<div class="newboxes" id="newboxes3">
<form class="form" method="POST">
<input type="text" id="nmPic" name="nmPic" placeholder="име на снимката" onfocus="this.placeholder = ''" onblur="this.placeholder = 'име на снимката'"></br>
<input type="text" id="price" class="priceFrom" name="priceFrom" placeholder="цена от" onfocus="this.placeholder = ''" onblur="this.placeholder = 'цена от'"></br>
<input type="text" id="price" class="priceTo" name="priceTo" placeholder="цена до" onfocus="this.placeholder = ''" onblur="this.placeholder = 'цена до'"></br>
<select name="picCat" id="picCat">
<option value="" selected disabled>Изберете категория</option>
<option value="Детски">Детски</option>
<option value="Сватби">Сватби</option>
<option value="Рожден ден">Рожден ден</option>
<option value="18+">18+</option>
<option value="Други">Други</option>
</select></br>
<input type="text" id="numPic" name="numPic" placeholder="номер на снимката" onfocus="this.placeholder = ''" onblur="this.placeholder = 'номер на снимката'"></br>
<input type="submit" name="showFilter" value="покажи" />
</form>
</div>
</div>
</div>
Code: php
<div class="row">
<div class="col-md-12 col-centered pic">
<form class='form' method='POST'>
<?php
if (isset($_POST["showFilter"]))
{
$picName = $_POST['nmPic'];
$priceFrom = $_POST['priceFrom'];
$priceTo = $_POST['priceTo'];
$picCat = isset($_POST['picCat']) ? $_POST['picCat'] : '';
$numPic = $_POST['numPic'];
$filter = " SELECT * FROM images WHERE status = '1'";
if ($numPic && !empty($numPic)) {
$filter .= " AND id='$numPic'";
}
if ($picName && !empty($picName)) {
$filter .= " AND img_content='$picName'";
}
if ($picCat && !empty($picCat)) {
$filter .= " AND category='$picCat'";
}
if ($priceTo && !empty($priceTo)) {
$filter .= " AND price < '$priceTo'+1";
}
if ($priceFrom && !empty($priceFrom)) {
$filter .= " AND price > '$priceFrom'";
}
$resFilter = $connect->query($filter);
if ($resFilter->num_rows > 0) {
while($row = mysqli_fetch_array($resFilter))
{
echo "<div class='col-md-3 picture'>
<img class='child-img' src='".$row["picture"]." '/></br>
<div class='number'>
<span class='id'>№ ".$row['id']."</br>
име: ".$row['img_content']."</br> категория: ".$row['category']."</br>
цена: ".$row['price']."лв.</br>
дата: ".$row['time']."ч.</br>
</span>
<input type='hidden' name='del' value=" .$row['id'].">
<input class='btn btn-danger' name='delete' type='submit' value='истрии'/>
</div>
</div>";
}
}
}
?>
</form>
</div>
</div>
<form method="POST">
<?php
if (isset($_POST['delete']))
{
$sql = "SELECT * FROM images WHERE status = '1'";
$res = $connect->query($sql);
while($row = mysqli_fetch_array($res))
{
$id = $_POST['del'];
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'paspartu';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = 'DELETE FROM images
WHERE id='.$id;
mysql_select_db('login');
mysql_query($sql);
mysql_close($conn);
}
}
?>
</form>
If pressed the delete button <input class="btn btn-danger" name="delete" type="submit" value="истрии"> , this delete the last upload image???
And can you tell me how to delete the image from upload folder "uploads/"? Thank you verry much.
It's because you don't have an input in your form that's named "showFilter". You need to either rewrite or remove:
if (isset($_POST["showFilter"]))
Try modified query delete
$sql = "DELETE FROM `your_database`.`images` WHERE `your_database`.`id` = $del_id";
As I can see your submit button is in separate form tag. That is why the button is responsible only for the first parent form and if it is pressed the page is only reloaded. It should be placed in the general form you use, so that it will be related with the general form action.
You need to take your submit button inside the form. You have used two different forms. It is the problem.
Try to write your code as below:-
<?php
// Take div and form tag outside the loop
echo "<div class='col-md-3 picture'>
<form class='form' method='POST'>";
// Loop start
while($row = mysqli_fetch_array($resFilter))
{
echo "<img class='child-img' src='".$row["picture"]." '/></br>
<div class='number'>
<span class='id'>№ ".$row['id']."
<input class='check' name='checkbox[]' type='checkbox' value='". $row['id']."'></br>
име: ".$row['img_content']."</br> категория: ".$row['category']."</br>
цена: ".$row['price']."лв.</br>
дата: ".$row['time']."ч.
</br></span>
<br></div>";
}
// Loop End
?>
<!-- submit button -->
<input class="btn btn-danger" name="delete" type="submit" value="истрии маркираните">
<?php
// end div and form tag outside the loop
echo "</form>
</div>";
if (isset($_POST['delete']) && isset($_POST['checkbox'])) {
foreach($_POST['checkbox'] as $del_id){
$del_id = (int)$del_id;
$sql = "DELETE FROM images WHERE id = $del_id";
mysql_query($sql);
}
header('Location: admin.php');
}
Hope it will help you :)