PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <html>
- <head>
- <style>
- h2 {text-align: center;}
- table {border: 1px solid darkgray;width: 40%;margin: auto}
- td {width: 50%;border: 1px solid darkgray;text-align: center;}
- </style>
- </head>
- <body>
- <?PHP
- //$mysqli = new mysqli('localhost','root','','tasks'); - может оно еще понадобиться вне функции?
- function tasks($x) {
- global $mysqli;
- $mysqli = new mysqli('localhost','root','','tasks');
- echo "<table><caption>".$x."</caption>";
- $query = $mysqli->query("SELECT * FROM `tasks` WHERE `status` LIKE '$x' ORDER BY char_length(`description`) ASC");
- while($new_tasks = $query->fetch_array()){
- echo "<tr><td>".$new_tasks['description']."</td><td>".$new_tasks['status']."</td></tr>";
- }
- echo "</table><br><br><br>";
- }
- echo"<h2>Список задач</h2>";
- // Новые задания
- $x = 'Не начато';
- tasks($x);
- //В процессе
- $x = 'В процессе';
- tasks($x);
- //Выполнено
- $x = 'Выполнено';
- tasks($x);
- echo '<table><caption>Ввод данных</caption>
- <form action="add.php" method="post">
- <tr><td> <p>Описание:</p></td> <td><textarea rows="1" cols="50" name="description"></textarea></td></tr>
- <tr><td> <p>Статус:</p> <td><textarea rows="1" cols="50" name="status"></textarea></td></tr></td></tr></table>
- <p style="text-align: center"><input type="submit" /></p>
- </form>';
- ?>
- </body>
- </html>