Не работает куки не знаю в чем причина
PHP код:
<?php
setcookie("lab45", $cooly,time()+3600);
?>
<form method="get">
Фон таблицы:
<select name="bgcolor">
<option value="red"> red </option>
<option value="green"> green </option>
</select>
<br>
Цвет текста:
<select name="text_color">
<option value="red"> red </option>
<option value="green"> green </option>
</select>
<br>
Толщина рамки:
<select name="border">
<option value="10"> 10 </option>
<option value="20"> 20 </option>
</select>
<input type="submit" id ="uio" value="ok">
</form>
<?php
$bgcolor = "green";
if (isset($_GET['bgcolor']))
$bgcolor = $_GET['bgcolor'];
$text_color = "white";
if (isset($_GET['text_color']))
$text_color = $_GET['text_color'];
$border= "15";
if (isset($_GET['border']))
$border = $_GET['border'];
class Array2D {
public $array = array();
public $array_columns = array();
public $sort_type = "";
public function __construct($array) {
$this->array_columns = $array[0];
unset($array[0]);
$this->array = $array;
$this->sort_type = $_GET['sort_type'];
}
public function show($table_border = "1", $table_bgcolor = "white", $table_text_color = "black")
{
echo "<table align = center bgcolor = {$table_bgcolor} border = {$table_border}>";
foreach ($this->array_columns as $column)
{
echo "<td> <font color = {$table_text_color}> {$column}";
if ($column == $this->array_columns[0]) {
echo "<a href='?sort_type=1_asc&bgcolor={$table_bgcolor}&text_color={$table_text_color}&border={$table_border}' style=text-decoration:none> ↓ </a>";
echo "<a href='?sort_type=1_desc&bgcolor={$table_bgcolor}&text_color={$table_text_color}&border={$table_border}' style=text-decoration:none> ↑ </a>";
} else if ($column == $this->array_columns[1]) {
echo "<a href='?sort_type=2_asc&bgcolor={$table_bgcolor}&text_color={$table_text_color}&border={$table_border}' style=text-decoration:none> ↓ </a>";
echo "<a href='?sort_type=2_desc&bgcolor={$table_bgcolor}&text_color={$table_text_color}&border={$table_border}' style=text-decoration:none> ↑ </a>";
}
echo "</font> </td>";
}
foreach ($this->array as $column) {
echo "<tr>";
foreach ($column as $row) {
if ($row == $column[2]) {
echo "<td align = center> <img src={$row} width=50%> </td>";
} else {
echo "<td> <font color = {$table_text_color}> {$row} </font> </td>";
}
}
echo "</tr>";
}
echo "</table>";
}
public function sort() {
function asc1($a, $b) {
if ($a[0] == $b[0]) {
return 0;
} else if ($a[0] > $b[0]) {
return 1;
} else if ($a[0] < $b[0]) {
return -1;
}
}
function desc1($a, $b) {
if ($a[0] == $b[0]) {
return 0;
} else if ($a[0] > $b[0]) {
return -1;
} else if ($a[0] < $b[0]) {
return 1;
}
}
function asc2($a, $b) {
if ($a[1] == $b[1]) {
return 0;
} else if ($a[1] > $b[1]) {
return 1;
} else if ($a[1] < $b[1]) {
return -1;
}
}
function desc2($a, $b) {
if ($a[1] == $b[1]) {
return 0;
} else if ($a[1] > $b[1]) {
return -1;
} else if ($a[1] < $b[1]) {
return 1;
}
}
if ($this->sort_type == "1_asc") {
usort($this->array, "asc1");
} else if ($this->sort_type == "1_desc") {
usort($this->array, "desc1");
} else if ($this->sort_type == "2_asc") {
usort($this->array, "asc2");
} else if ($this->sort_type == "2_desc") {
usort($this->array, "desc2");
}
}
public function get_sort_type() {
return $this->sort_type;
}
}
$array = array( array('ФИО Студента', 'Группа', 'Графическое изображение'),
array('Иванов И.И.', '525', 'images/42.jpg'),
array('Петров П.П', '525', 'images/images.jpg'),
array('Сидоров С.С.', '526', 'images/Pikachu.png'),
array('Иванов И.Т.', '526', 'images/pokemonMeawth.jpeg')
);
$object = new Array2D($array);
$object->sort();
$cooly=$object->get_sort_type();
$object->show($border, $bgcolor, $text_color);
?>