Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Скриптовые языки программирования > PHP
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 01.05.2015, 08:40   #1
фыг
Новичок
Джуниор
 
Регистрация: 01.05.2015
Сообщений: 1
По умолчанию Помощь с COOKIE

Не работает куки не знаю в чем причина
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> &darr; </a>";
                    echo 
"<a href='?sort_type=1_desc&bgcolor={$table_bgcolor}&text_color={$table_text_color}&border={$table_border}' style=text-decoration:none> &uarr; </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> &darr; </a>";
                    echo 
"<a href='?sort_type=2_desc&bgcolor={$table_bgcolor}&text_color={$table_text_color}&border={$table_border}' style=text-decoration:none> &uarr; </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);
?>

Последний раз редактировалось Вадим Мошев; 01.05.2015 в 14:29.
фыг вне форума Ответить с цитированием
Старый 01.05.2015, 09:00   #2
Andkorol
Старожил
 
Регистрация: 31.05.2010
Сообщений: 3,301
По умолчанию

Оформляем код:


В данном случае – и не должно работать, т.к. переменная $cooly на момент установки cookies не определена.
Andkorol вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
COOKIE economic_man PHP 7 01.03.2015 23:12
GET + cookie jone Мультимедиа в Delphi 2 05.09.2013 22:16
Cookie sem_1989 PHP 16 10.08.2011 00:13
Cookie Indy Aleksandr69 Работа с сетью в Delphi 3 04.01.2011 14:46
Проблема с Cookie eldar Работа с сетью в Delphi 5 21.08.2008 13:27