PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи

Страниц (2): [1] 2 »

> Найдено сообщений: 21
Noganno Отправлено: 13 Апреля, 2011 - 13:14:07 • Тема: Перенаправление из функции • Форум: Программирование на PHP

Ответов: 31
Просмотров: 1886
тогда поставь echo "<meta http-equiv=refresh content=0;url=http://site.ru/main.php>";
реально лень попробовать?
Noganno Отправлено: 02 Апреля, 2011 - 13:55:57 • Тема: PHP+MySql • Форум: Программирование на PHP

Ответов: 4
Просмотров: 448
Посмотри кодировку файла
Noganno Отправлено: 02 Апреля, 2011 - 13:54:26 • Тема: кто поможет создать форму обратной связи? • Форум: Программирование на PHP

Ответов: 6
Просмотров: 545
Таких скриптов на просторах инета валом, 'авторизация и регистрация пользователя ajax'
Noganno Отправлено: 19 Марта, 2011 - 09:56:51 • Тема: Как сделать выборку • Форум: Программирование на PHP

Ответов: 6
Просмотров: 350
Champion Спасибо большое, все получилось, правда пришлось в таблице post переименовать строку id в post_id и запрос получился такой
CODE (SQL):
скопировать код в буфер обмена
  1.  
  2. SELECT *
  3. FROM post AS p
  4. LEFT JOIN copypaste AS cp USING (post_id)
  5. WHERE p.author_id = 2 OR cp.author_id = 2
  6.  
Noganno Отправлено: 18 Марта, 2011 - 15:28:40 • Тема: Как сделать выборку • Форум: Программирование на PHP

Ответов: 6
Просмотров: 350
В данном случае он выводит только те записи которые присутствуют в таблице copypaste
LEFT JOIN тоже к сожалению не подходит
Noganno Отправлено: 18 Марта, 2011 - 15:00:31 • Тема: Как сделать выборку • Форум: Программирование на PHP

Ответов: 6
Просмотров: 350
EuGen пишет:
Если Вы делаете SELECT * {...}, то получаете вообще все посты - вне зависимости, указаны они где-то или нет. Или я не правильно понимаю задачу?


До сегодняшнего моменты у меня была одна таблица с постами и оттуда я делал выборку.
например:
PHP:
скопировать код в буфер обмена
  1.  
  2. SELECT * FROM post WHERE author_id = 1
  3.  

после я расширил функционал работы над постами и теперь появилась вторая таблица copypaste в которой заносятся некоторые посты с id пользователя. Поэтому теперь мне надо вывести все посты определенного пользователя из основной таблицы post и дополнительной copypaste где присутствует его user_id
Noganno Отправлено: 18 Марта, 2011 - 14:35:11 • Тема: Как сделать выборку • Форум: Программирование на PHP

Ответов: 6
Просмотров: 350
Есть таблица post и таблица copypaste

CODE (SQL):
скопировать код в буфер обмена
  1.  
  2. CREATE TABLE IF NOT EXISTS `post` (
  3.   `id` int(11) NOT NULL AUTO_INCREMENT,
  4.   `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  5.   `text` text COLLATE utf8_unicode_ci NOT NULL,
  6.   `author_id` int(11) NOT NULL,
  7.   PRIMARY KEY (`id`)
  8. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
  9.  
  10. --
  11. -- Дамп данных таблицы `post`
  12. --
  13.  
  14. INSERT INTO `post` (`id`, `title`, `text`, `author_id`) VALUES
  15. (1, 'test 1', 'test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 test 1 ', 1),
  16. (2, 'test 2', 'test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 test 2 ', 1),
  17. (3, 'test 3', 'test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  test 3 test 3  ', 1),
  18. (4, 'test 4', 'test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  test 4 test 4  ', 2),
  19. (5, 'test 5 ', 'test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  test 5 test 5  ', 1),
  20. (6, 'test 6', 'test 6 test 6   test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  test 6 test 6  ', 2);
  21.  
  22.  
  23. CREATE TABLE IF NOT EXISTS `copypaste` (
  24.   `id` int(11) NOT NULL AUTO_INCREMENT,
  25.   `post_id` int(11) DEFAULT NULL,
  26.   `user_id` int(11) DEFAULT NULL,
  27.   `author_id` int(11) NOT NULL,
  28.   PRIMARY KEY (`id`),
  29.   KEY `user_id` (`user_id`)
  30. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
  31.  
  32. --
  33. -- Дамп данных таблицы `copypaste`
  34. --
  35.  
  36. INSERT INTO `copypaste` (`id`, `post_id`, `user_id`, `author_id`) VALUES
  37. (1, 1, 2, 1),
  38. (2, 2, 2, 1);
  39.  


Я вывожу посты из таблицы post


Каким образом мне надо создать запрос, чтобы помимо постов из таблицы post, мне также выводились посты id которых указаны еще и в таблице copypaste?
Noganno Отправлено: 15 Марта, 2011 - 14:35:03 • Тема: Восстановление пароля • Форум: Программирование на PHP

Ответов: 5
Просмотров: 1972
Попробуй так
CODE (htmlphp):
скопировать код в буфер обмена
  1.  
  2.  
  3. SELECT id FROM users WHERE username='".$login."' AND usermail='".$email."' AND activation='1'
  4.  
Noganno Отправлено: 11 Марта, 2011 - 09:53:48 • Тема: Обратная связь и кодировка UTF-8 • Форум: Программирование на PHP

Ответов: 7
Просмотров: 648
Для перекодирования в UTF8 попробуйте свой файл открыть в программе Notepad++ там во вкладке кодировки, выбираете нужную вам
Noganno Отправлено: 03 Марта, 2011 - 12:56:02 • Тема: Как загрузить через форму сразу несколько файлов? • Форум: Программирование на PHP

Ответов: 5
Просмотров: 933
А print_r($_FILES) что выводит? Может у вас где то пустые значения или совпадающие
Noganno Отправлено: 14 Февраля, 2011 - 14:08:18 • Тема: проблема с crop в Safari • Форум: Программирование на PHP

Ответов: 0
Просмотров: 181
Есть код:
CODE (htmlphp):
скопировать код в буфер обмена
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4.         <head>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.         <link rel="stylesheet" type="text/css" href="/css/style_avatar.css">
  7.         <link rel="stylesheet" type="text/css" href="/css/imgareaselect-deprecated.css">
  8.         <script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
  9.         <script type="text/javascript" src="/js/ajaxupload.js"></script>
  10.         <script type="text/javascript" src="/js/jquery.imgareaselect.min.js"></script>
  11.         <script type="text/javascript">
  12.         $(document).ready(function(){
  13.                 var button = $('#butUpload > span'), interval, image, widthImg, heightImg, thumbW, thumbH;
  14.                
  15.                 new AjaxUpload(button, {
  16.                         action: 'upload.php',
  17.                         onSubmit : function(file, ext){
  18.                         if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)) {
  19.                                 button.text('Загружается');
  20.                                 this.disable();
  21.                                 $("#imgLoad").show();
  22.                                
  23.                                 interval = window.setInterval(function(){
  24.                                         var text = button.text();
  25.                                        
  26.                                         if (text.length < 13){
  27.                                                 button.text(text + '.');                                       
  28.                                         } else {
  29.                                                 button.text('Загружается');                            
  30.                                         }
  31.                                 }, 200);
  32.                                 } else {
  33.                                         alert("Ошибка, только jpg, png, jpeg, gif");
  34.                                         return false;
  35.                                 }
  36.                         },
  37.                         onComplete: function(file, response){
  38.                                 $("#imgLoad").hide();
  39.                                 button.text('Выбрать другое');
  40.                                
  41.                                 window.clearInterval(interval);
  42.                                
  43.                                 image = file;          
  44.                                 var ajaxObj = JSON.parse(response);
  45.                                 //var ajaxObj = JSON.parse(response);
  46.                                 widthImg = ajaxObj.width;
  47.                                 heightImg = ajaxObj.height;
  48.                                 thumbW = ajaxObj.thumbW;
  49.                                 thumbH = ajaxObj.thumbH;
  50.                                
  51.                                 $("#preview").css({'width': thumbW+'px', 'height': thumbH+'px'});
  52.                                 $("#min_thumbnail").css({'width': thumbW+'px', 'height': thumbH+'px'});
  53.                                
  54.                                 this.enable();
  55.                                
  56.                                 view(file);                                            
  57.                         }
  58.                 });
  59.                
  60.                 function view (imgName) {
  61.                
  62.                         $("#imgEdit").show();
  63.                        
  64.                         $("#thumbnail").attr("src","http://site.com/uploads/"+imgName);
  65.                         $("#min_thumbnail").attr("src","http://site.com/uploads/"+imgName);
  66.                 }
  67.                
  68.                 $("#thumbnail").imgAreaSelect({aspectRatio: '1:1', handles: true, fadeSpeed: 200, onSelectChange: preview});
  69.                
  70.                 function preview (img, selection) {
  71.                         if (!selection.width || !selection.height)
  72.                                 return;
  73.                                
  74.                         var scaleX = thumbW / selection.width;
  75.                         var scaleY = thumbH / selection.height;
  76.                        
  77.                         $("#min_thumbnail").css({
  78.                                 width: Math.round(scaleX * widthImg),
  79.                                 height: Math.round(scaleY * heightImg),
  80.                                 marginLeft: -Math.round(scaleX * selection.x1),
  81.                                 marginTop: -Math.round(scaleY * selection.y1)
  82.                         });
  83.                        
  84.                         $("#x1").val(selection.x1);
  85.                         $("#y1").val(selection.y1);
  86.                         $("#x2").val(selection.x2);
  87.                         $("#y2").val(selection.y2);
  88.                         $("#w").val(selection.width);
  89.                         $("#h").val(selection.height);
  90.                        
  91.                 }
  92.                
  93.                 $("#butSave").click(function () {
  94.                
  95.                         var x1 = $("#x1").val();
  96.                         var y1 = $("#y1").val();
  97.                         var x2 = $("#x2").val();
  98.                         var y2 = $("#y2").val();
  99.                         var w = $("#w").val();
  100.                         var h = $("#w").val();
  101.                         $.ajax ({
  102.                                 url: "upload.php",
  103.                                 type: "POST",
  104.                                 data: {image: image, x1: x1, y1: y1, x2: x2, y2: y2, w: w, h: h},
  105.                                 success: function () {newAvatar(image);}
  106.                        
  107.                         });
  108.                
  109.                         function newAvatar (avatar) {
  110.                                 $("#thumbnail").imgAreaSelect({hide: true});
  111.                                 $("#avatar").html("<img src=\"http://site.com/uploads/"+avatar+"\" width=\"200\">");
  112.                                 $("#minImg").html("<img src=\"http://site.com/uploads/min_"+avatar+"\">");
  113.                                 $("#imgEdit").hide();
  114.              
  115.                         }
  116.                
  117.                 });
  118.                
  119.         });
  120.         </script>
  121.         </head>
  122.         <body>    
  123. <div id="main">
  124.       <div id="wrapper">
  125.     <div id="content">
  126.           <div id="avatar2"></div>
  127.           <div id="minImg"></div>
  128.           <div style="clear:both"></div>
  129.                     <div id="butUpload"><span>Выберите фото</span><img src="/img/loading.gif" id="imgLoad"
  130.  
  131. align="right" /></div>
  132.           <div id="imgEdit"> <img src="" style="float: left; margin-right: 10px;" id="thumbnail" />
  133.         <div id="preview" style="width: 100px; height: 100px; overflow: hidden;"> <img src="" style="width: 100px; height: 100px;" id="min_thumbnail" /> </div>
  134.         <br style="clear:both;"/>
  135.         <form name="thumbnail">
  136.               <input type="hidden" name="x1" value="" id="x1" />
  137.               <input type="hidden" name="y1" value="" id="y1" />
  138.               <input type="hidden" name="x2" value="" id="x2" />
  139.               <input type="hidden" name="y2" value="" id="y2" />
  140.               <input type="hidden" name="w" value="" id="w" />
  141.               <input type="hidden" name="h" value="" id="h" />
  142.             </form>
  143.             <div style="clear:both"></div>
  144.         <div id="butSave">Сохранить</div>
  145.       </div>
  146.         </div>
  147.     <!--end content-->
  148.   </div>
  149.       <!--end wrapper-->
  150.      
  151.     </div>
  152.     <!--end main-->
  153.  
  154.  
  155. </body>
  156. </html>
  157.  


Все работает, делает загрузку и ручной crop изображения. Работает в браузерах Opera, Mozzila, Google Hrom, а вот в IE и Safari отказывается работать. После загрузке изображения на сервер, не выводит его на экран, для того чтобы пользователь смог сделать crop. IE ругается на 44 строчку. Каким либо образом можно решить эту проблему?
Noganno Отправлено: 14 Февраля, 2011 - 11:39:25 • Тема: функция конвертора валют с google • Форум: Пользовательские функции

Ответов: 3
Просмотров: 460
Что то какой то топорный, сделай лучше без перезагрузки страницы, что результаты мгновенно показывались, в соседнем окне, а то очень неудобный.
Noganno Отправлено: 14 Февраля, 2011 - 11:35:08 • Тема: Можно ли "дописать" session_destroy? • Форум: Программирование на PHP

Ответов: 4
Просмотров: 353
Записываешь сессию юзера в базу с временем, когда он зашел на сайт, если человек ушел с сайта, удаляешь сессию из базы. Трогать сессии не придется.
Noganno Отправлено: 10 Февраля, 2011 - 18:02:47 • Тема: Проблема с кодировкой • Форум: Программирование на PHP

Ответов: 5
Просмотров: 443
grefon пишет:
Добавьте в текст хоть один символ, который не входит в стандартную латиницу и у Вас будет UTF8 без bom.


Добавляю текст, только сохранят файл мне в UTF 8, когда пытаюсь переконвертировать его в Без BOM опять перекидывает его на ANSI
Noganno Отправлено: 10 Февраля, 2011 - 15:08:34 • Тема: Проблема с кодировкой • Форум: Программирование на PHP

Ответов: 5
Просмотров: 443
CODE (htmlphp):
скопировать код в буфер обмена
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4.         <head>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.         <link rel="stylesheet" type="text/css" href="/css/style_avatar.css">
  7.         <link rel="stylesheet" type="text/css" href="/css/imgareaselect-deprecated.css">
  8.         <script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
  9.         <script type="text/javascript" src="/js/ajaxupload.js"></script>
  10.         <script type="text/javascript" src="/js/jquery.imgareaselect.min.js"></script>
  11.         <script type="text/javascript">
  12.         $(document).ready(function(){
  13.                 var button = $('#butUpload > span'), interval, image, widthImg, heightImg, thumbW, thumbH;
  14.                
  15.                 new AjaxUpload(button, {
  16.                         action: 'upload.php',
  17.                         onSubmit : function(file, ext){
  18.                         if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)) {
  19.                                 button.text('Upload');
  20.                                 this.disable();
  21.                                 $("#imgLoad").show();
  22.                                
  23.                                 interval = window.setInterval(function(){
  24.                                         var text = button.text();
  25.                                        
  26.                                         if (text.length < 13){
  27.                                                 button.text(text + '.');                                       
  28.                                         } else {
  29.                                                 button.text('Upload');                         
  30.                                         }
  31.                                 }, 200);
  32.                                 } else {
  33.                                         alert("Error, only jpg, png, jpeg, gif");
  34.                                         return false;
  35.                                 }
  36.                         },
  37.                         onComplete: function(file, response){
  38.                                 $("#imgLoad").hide();
  39.                                 button.text('Upload yet?');
  40.                                
  41.                                 window.clearInterval(interval);
  42.                                
  43.                                 image = file;
  44.                                
  45.                                 var ajaxObj = JSON.parse(response);
  46.                                
  47.                                 widthImg = ajaxObj.width;
  48.                                 heightImg = ajaxObj.height;
  49.                                 thumbW = ajaxObj.thumbW;
  50.                                 thumbH = ajaxObj.thumbH;
  51.                                
  52.                                 $("#preview").css({'width': thumbW+'px', 'height': thumbH+'px'});
  53.                                 $("#min_thumbnail").css({'width': thumbW+'px', 'height': thumbH+'px'});
  54.                                
  55.                                 this.enable();
  56.                                
  57.                                 view(file);                                            
  58.                         }
  59.                 });
  60.                
  61.                 function view (imgName) {
  62.                
  63.                         $("#imgEdit").show();
  64.                        
  65.                         $("#thumbnail").attr("src","http://quazza.com/uploads/"+imgName);
  66.                         $("#min_thumbnail").attr("src","http://quazza.com/uploads/"+imgName);
  67.                 }
  68.                
  69.                 $("#thumbnail").imgAreaSelect({aspectRatio: '1:1', handles: true, fadeSpeed: 200, onSelectChange: preview});
  70.                
  71.                 function preview (img, selection) {
  72.                         if (!selection.width || !selection.height)
  73.                                 return;
  74.                                
  75.                         var scaleX = thumbW / selection.width;
  76.                         var scaleY = thumbH / selection.height;
  77.                        
  78.                         $("#min_thumbnail").css({
  79.                                 width: Math.round(scaleX * widthImg),
  80.                                 height: Math.round(scaleY * heightImg),
  81.                                 marginLeft: -Math.round(scaleX * selection.x1),
  82.                                 marginTop: -Math.round(scaleY * selection.y1)
  83.                         });
  84.                        
  85.                         $("#x1").val(selection.x1);
  86.                         $("#y1").val(selection.y1);
  87.                         $("#x2").val(selection.x2);
  88.                         $("#y2").val(selection.y2);
  89.                         $("#w").val(selection.width);
  90.                         $("#h").val(selection.height);
  91.                        
  92.                 }
  93.                
  94.                 $("#butSave").click(function () {
  95.                
  96.                         var x1 = $("#x1").val();
  97.                         var y1 = $("#y1").val();
  98.                         var x2 = $("#x2").val();
  99.                         var y2 = $("#y2").val();
  100.                         var w = $("#w").val();
  101.                         var h = $("#w").val();
  102.                         $.ajax ({
  103.                                 url: "upload.php",
  104.                                 type: "POST",
  105.                                 data: {image: image, x1: x1, y1: y1, x2: x2, y2: y2, w: w, h: h},
  106.                                 success: function () {newAvatar(image);}
  107.                        
  108.                         });
  109.                
  110.                         function newAvatar (avatar) {
  111.                                 $("#thumbnail").imgAreaSelect({hide: true});
  112.                                 $("#avatar").html("<img src=\"http://quazza.com/uploads/"+avatar+"\" width=\"200\">");
  113.                                 $("#minImg").html("<img src=\"http://quazza.com/uploads/min_"+avatar+"\">");
  114.                                 $("#imgEdit").hide();
  115.              
  116.                         }
  117.                
  118.                 });
  119.                
  120.         });
  121.         </script>
  122.         </head>
  123.  
  124.         <body>
  125. <div id="main">
  126.       <div id="wrapper">
  127.     <div id="content">
  128.           <div id="avatar">Avatar</div>
  129.           <div id="minImg"></div>
  130.           <div style="clear:both"></div>
  131.                     <div id="butUpload"><span>To replace</span><img src="/img/loading.gif" id="imgLoad"
  132.  
  133. align="right" /></div>
  134.           <div id="imgEdit"> <img src="" style="float: left; margin-right: 10px;" id="thumbnail" />
  135.         <div id="preview" style="width: 100px; height: 100px; overflow: hidden;"> <img src="" style="width: 100px; height: 100px;" id="min_thumbnail" /> </div>
  136.         <br style="clear:both;"/>
  137.         <form name="thumbnail">
  138.               <input type="hidden" name="x1" value="" id="x1" />
  139.               <input type="hidden" name="y1" value="" id="y1" />
  140.               <input type="hidden" name="x2" value="" id="x2" />
  141.               <input type="hidden" name="y2" value="" id="y2" />
  142.               <input type="hidden" name="w" value="" id="w" />
  143.               <input type="hidden" name="h" value="" id="h" />
  144.             </form>
  145.         <div id="butSave">Save</div>
  146.       </div>
  147.         </div>
  148.     <!--end content-->
  149.   </div>
  150.       <!--end wrapper-->
  151.      
  152.     </div>
  153. <!--end main-->
  154. </body>
  155. </html>
  156.  
  157.  

Страниц (2): [1] 2 »
Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB