It is necessary to change the results depending on the choice of chekbox / option, and bind these actions to the button. The problem is that the button does not respond to the onclick = "****. Php" attribute. In general, here’s the code:

<div class="logic"> <form action="main.php" method="post"> <input type="checkbox" name="pdf" value="pdf"><a>pdf</a> <br> <input type="checkbox" name="djvu"><a>djvu</a> <br> <input type="checkbox" name="fb2"><a>fb2</a> <br> <input type="checkbox" name="anything"><a>Любой формат</a> <br> <a>Сортировать: </a> <br> <select name="sorting"> <option disabled selected value="Выберите сортировку">Выберите сортировку</option> <option value="decrease_sort" id="decrease_sort">Сортировка по убыванию</option> <option value="increase_sort">Сортировка по возрастанию</option> <option value="authors_sort">Сортировка по авторам</option> </select> <br> <br> <input type="button" value="Подтвердить" name="confirmButton" class="button button1"> <input class="button button2" type="reset" value="Сбросить" name="Сбросить"> </form> </div> <iframe src="main.php" width="50%" height="100%" class="frame"></iframe> 

 <?php $link = mysqli_connect('localhost','root','','mydb'); mysqli_set_charset($link,'utf-8'); if(!($link)){ die('error of connection' .mysql_error()); } if(isset($_POST['increase_sort'])){ $query = "SELECT * FROM издательство ORDER BY Год_издания ASC"; $result = mysqli_query($link,$query); while($i = mysqli_fetch_array($result)){ echo $i['Наименование']. "-\t </br> <b>Год:</b> \t"; echo $i['Год_издания']. ", \t <b>Страниц:</b> \t "; echo $i['Количество_страниц']. " </br>"; } }else if(isset($_POST['decrease_sort'])){ $query = "SELECT * FROM издательство ORDER BY Год_издания DESC"; $result = mysqli_query($link,$query); while($i = mysqli_fetch_array($result)){ echo $i['Наименование']. "-\t </br> <b>Год:</b> \t"; echo $i['Год_издания']. ", \t <b>Страниц:</b> \t "; echo $i['Количество_страниц']. " </br>"; } }else{ $query = "SELECT * FROM издательство"; $result = mysqli_query($link,$query); while($i = mysqli_fetch_array($result)){ echo $i['Наименование']. "-\t </br> <b>Год:</b> \t"; echo $i['Год_издания']. ", \t <b>Страниц:</b> \t "; echo $i['Количество_страниц']. " </br></br>"; } } mysqli_close($link); ?> 
  • Tag <br> - single tag: it is not necessary to close it. - Roman Grinyov

1 answer 1

 <input type="button" value="Подтвердить" name="confirmButton" class="button button1"> 

Replaced by:

 <input type="submit" value="Подтвердить" name="confirmButton" class="button button1"> 

Then

 <form action="main.php" method="post"> 

Replaced by:

<form action="main.php" method="post" target="fc_iframe">

and

<iframe src="main.php" width="50%" height="100%" class="frame" ></iframe> on <iframe name="fc_iframe" src="main.php" width="50%" height="100%" class="frame" ></iframe>

  • A separate .php page is loaded. How to attach to an iframe? - santaasus s
  • <form action = "main.php" method = "post"> Replace with: <form action = "main.php" method = "post" target = "fc_iframe"> and <iframe src = "main.php" width = "50%" height = "100%" class = "frame"> </ iframe> on <iframe name = "fc_iframe" src = "main.php" width = "50%" height = "100%" class = " frame "> </ iframe> - Fəqan Çələbizadə