PHP . SU
Программирование на PHP, MySQL и другие веб-технологии
Страниц (2): [1] 2 »
Найдено сообщений: 21
Noganno
Отправлено: 19 Марта, 2011 - 09:56:51 • Тема: Как сделать выборку • Форум: Программирование на PHP
Ответов: 6 Просмотров: 350
Champion Спасибо большое, все получилось, правда пришлось в таблице post переименовать строку id в post_id и запрос получился такой
Noganno
Отправлено: 18 Марта, 2011 - 15:28:40 • Тема: Как сделать выборку • Форум: Программирование на PHP
Ответов: 6 Просмотров: 350
В данном случае он выводит только те записи которые присутствуют в таблице copypaste
LEFT JOIN тоже к сожалению не подходит
Noganno
Отправлено: 18 Марта, 2011 - 15:00:31 • Тема: Как сделать выборку • Форум: Программирование на PHP
Ответов: 6 Просмотров: 350
EuGen пишет: Если Вы делаете SELECT * {...}, то получаете вообще все посты - вне зависимости, указаны они где-то или нет. Или я не правильно понимаю задачу?
До сегодняшнего моменты у меня была одна таблица с постами и оттуда я делал выборку.
например:
после я расширил функционал работы над постами и теперь появилась вторая таблица copypaste в которой заносятся некоторые посты с id пользователя. Поэтому теперь мне надо вывести все посты определенного пользователя из основной таблицы post и дополнительной copypaste где присутствует его user_id
Noganno
Отправлено: 18 Марта, 2011 - 14:35:11 • Тема: Как сделать выборку • Форум: Программирование на PHP
Ответов: 6 Просмотров: 350
Есть таблица post и таблица copypaste
CODE (
SQL ):
скопировать код в буфер обмена
CREATE TABLE IF NOT EXISTS `post` (
`id` int( 11) NOT NULL AUTO_INCREMENT ,
`title` varchar( 255) COLLATE utf8_unicode_ci NOT NULL ,
`text` text COLLATE utf8_unicode_ci NOT NULL ,
`author_id` int( 11) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE= MyISAM DEFAULT CHARSET= utf8 COLLATE= utf8_unicode_ci AUTO_INCREMENT = 7 ;
--
-- Дамп данных таблицы `post`
--
INSERT INTO `post` ( `id` , `title` , `text` , `author_id` ) VALUES
( 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 ) ,
( 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 ) ,
( 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 ) ,
( 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 ) ,
( 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 ) ,
( 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) ;
CREATE TABLE IF NOT EXISTS `copypaste` (
`id` int( 11) NOT NULL AUTO_INCREMENT ,
`post_id` int( 11) DEFAULT NULL ,
`user_id` int( 11) DEFAULT NULL ,
`author_id` int( 11) NOT NULL ,
PRIMARY KEY ( `id` ) ,
KEY `user_id` ( `user_id` )
) ENGINE= MyISAM DEFAULT CHARSET= utf8 COLLATE= utf8_unicode_ci AUTO_INCREMENT = 4 ;
--
-- Дамп данных таблицы `copypaste`
--
INSERT INTO `copypaste` ( `id` , `post_id` , `user_id` , `author_id` ) VALUES
( 1, 1, 2, 1) ,
( 2, 2, 2, 1) ;
Я вывожу посты из таблицы post
Каким образом мне надо создать запрос, чтобы помимо постов из таблицы post, мне также выводились посты id которых указаны еще и в таблице copypaste?
Noganno
Отправлено: 14 Февраля, 2011 - 14:08:18 • Тема: проблема с crop в Safari • Форум: Программирование на PHP
Ответов: 0 Просмотров: 181
Есть код:
CODE (
htmlphp ):
скопировать код в буфер обмена
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html>
< head>
< meta http- equiv= "Content-Type" content= "text/html; charset=utf-8" />
< link rel= "stylesheet" type= "text/css" href= "/css/style_avatar.css" >
< link rel= "stylesheet" type= "text/css" href= "/css/imgareaselect-deprecated.css" >
< script type= "text/javascript" src= "/js/jquery-1.4.4.min.js" ></ script>
< script type= "text/javascript" src= "/js/ajaxupload.js" ></ script>
< script type= "text/javascript" src= "/js/jquery.imgareaselect.min.js" ></ script>
< script type= "text/javascript" >
$( document) . ready( function( ) {
var button = $( '#butUpload > span' ) , interval, image, widthImg, heightImg, thumbW, thumbH;
new AjaxUpload( button, {
action: 'upload.php' ,
onSubmit : function( file , ext) { if ( ext && / ^( jpg| png| jpeg| gif) $/. test( ext) ) {
button. text( 'Загружается' ) ;
this. disable( ) ;
$( "#imgLoad" ) . show( ) ;
interval = window. setInterval( function( ) {
var text = button. text( ) ;
if ( text. length < 13 ) {
button. text( text + '.' ) ;
} else {
button. text( 'Загружается' ) ;
}
} , 200) ;
} else {
alert( "Ошибка, только jpg, png, jpeg, gif" ) ;
return false ;
}
} ,
onComplete: function( file , response) { $( "#imgLoad" ) . hide( ) ;
button. text( 'Выбрать другое' ) ;
window. clearInterval( interval) ;
var ajaxObj = JSON. parse( response) ;
//var ajaxObj = JSON.parse(response);
widthImg = ajaxObj. width;
heightImg = ajaxObj. height;
thumbW = ajaxObj. thumbW;
thumbH = ajaxObj. thumbH;
$( "#preview" ) . css( { 'width' : thumbW+ 'px' , 'height' : thumbH+ 'px' } ) ;
$( "#min_thumbnail" ) . css( { 'width' : thumbW+ 'px' , 'height' : thumbH+ 'px' } ) ;
this. enable( ) ;
}
} ) ;
function view ( imgName) {
$( "#imgEdit" ) . show( ) ;
$( "#thumbnail" ) . attr( "src" , "http://site.com/uploads/" + imgName) ;
$( "#min_thumbnail" ) . attr( "src" , "http://site.com/uploads/" + imgName) ;
}
$( "#thumbnail" ) . imgAreaSelect( { aspectRatio: '1:1' , handles: true , fadeSpeed: 200, onSelectChange: preview} ) ;
function preview ( img, selection) {
if ( ! selection. width || ! selection. height)
return ;
var scaleX = thumbW / selection. width;
var scaleY = thumbH / selection. height;
$( "#min_thumbnail" ) . css( {
width: Math. round ( scaleX * widthImg) , height: Math. round ( scaleY * heightImg) , marginLeft: - Math. round ( scaleX * selection. x1) , marginTop: - Math. round ( scaleY * selection. y1) } ) ;
$( "#x1" ) . val( selection. x1) ;
$( "#y1" ) . val( selection. y1) ;
$( "#x2" ) . val( selection. x2) ;
$( "#y2" ) . val( selection. y2) ;
$( "#w" ) . val( selection. width) ;
$( "#h" ) . val( selection. height) ;
}
$( "#butSave" ) . click( function ( ) {
var x1 = $( "#x1" ) . val( ) ;
var y1 = $( "#y1" ) . val( ) ;
var x2 = $( "#x2" ) . val( ) ;
var y2 = $( "#y2" ) . val( ) ;
var w = $( "#w" ) . val( ) ;
var h = $( "#w" ) . val( ) ;
$. ajax ( {
url: "upload.php" ,
type: "POST" ,
data: { image: image, x1: x1, y1: y1, x2: x2, y2: y2, w: w, h: h} ,
success: function ( ) { newAvatar( image) ; }
} ) ;
function newAvatar ( avatar) {
$( "#thumbnail" ) . imgAreaSelect( { hide: true } ) ;
$( "#avatar" ) . html( "<img src=\" http://site.com/uploads/" + avatar+ "\" width=\" 200\" >" ) ;
$( "#minImg" ) . html( "<img src=\" http://site.com/uploads/min_" + avatar+ "\" >" ) ;
$( "#imgEdit" ) . hide( ) ;
}
} ) ;
} ) ;
</ script>
</ head>
< body>
< div id= "main" >
< div id= "wrapper" >
< div id= "content" >
< div id= "avatar2" ></ div>
< div id= "minImg" ></ div>
< div style= "clear:both" ></ div>
< div id= "butUpload" >< span> Выберите фото</ span>< img src= "/img/loading.gif" id= "imgLoad"
align= "right" /></ div>
< div id= "imgEdit" > < img src= "" style= "float: left; margin-right: 10px;" id= "thumbnail" />
< div id= "preview" style= "width: 100px; height: 100px; overflow: hidden;" > < img src= "" style= "width: 100px; height: 100px;" id= "min_thumbnail" /> </ div>
< br style= "clear:both;" />
< form name= "thumbnail" >
< input type= "hidden" name= "x1" value= "" id= "x1" />
< input type= "hidden" name= "y1" value= "" id= "y1" />
< input type= "hidden" name= "x2" value= "" id= "x2" />
< input type= "hidden" name= "y2" value= "" id= "y2" />
< input type= "hidden" name= "w" value= "" id= "w" />
< input type= "hidden" name= "h" value= "" id= "h" />
</ form>
< div style= "clear:both" ></ div>
< div id= "butSave" > Сохранить</ div>
</ div>
</ div>
</ div>
</ div>
</ body>
</ html>
Все работает, делает загрузку и ручной crop изображения. Работает в браузерах Opera, Mozzila, Google Hrom, а вот в IE и Safari отказывается работать. После загрузке изображения на сервер, не выводит его на экран, для того чтобы пользователь смог сделать crop. IE ругается на 44 строчку. Каким либо образом можно решить эту проблему?
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 ):
скопировать код в буфер обмена
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html>
< head>
< meta http- equiv= "Content-Type" content= "text/html; charset=utf-8" />
< link rel= "stylesheet" type= "text/css" href= "/css/style_avatar.css" >
< link rel= "stylesheet" type= "text/css" href= "/css/imgareaselect-deprecated.css" >
< script type= "text/javascript" src= "/js/jquery-1.4.4.min.js" ></ script>
< script type= "text/javascript" src= "/js/ajaxupload.js" ></ script>
< script type= "text/javascript" src= "/js/jquery.imgareaselect.min.js" ></ script>
< script type= "text/javascript" >
$( document) . ready( function( ) {
var button = $( '#butUpload > span' ) , interval, image, widthImg, heightImg, thumbW, thumbH;
new AjaxUpload( button, {
action: 'upload.php' ,
onSubmit : function( file , ext) { if ( ext && / ^( jpg| png| jpeg| gif) $/. test( ext) ) {
button. text( 'Upload' ) ;
this. disable( ) ;
$( "#imgLoad" ) . show( ) ;
interval = window. setInterval( function( ) {
var text = button. text( ) ;
if ( text. length < 13 ) {
button. text( text + '.' ) ;
} else {
button. text( 'Upload' ) ;
}
} , 200) ;
} else {
alert( "Error, only jpg, png, jpeg, gif" ) ;
return false ;
}
} ,
onComplete: function( file , response) { $( "#imgLoad" ) . hide( ) ;
button. text( 'Upload yet?' ) ;
window. clearInterval( interval) ;
var ajaxObj = JSON. parse( response) ;
widthImg = ajaxObj. width;
heightImg = ajaxObj. height;
thumbW = ajaxObj. thumbW;
thumbH = ajaxObj. thumbH;
$( "#preview" ) . css( { 'width' : thumbW+ 'px' , 'height' : thumbH+ 'px' } ) ;
$( "#min_thumbnail" ) . css( { 'width' : thumbW+ 'px' , 'height' : thumbH+ 'px' } ) ;
this. enable( ) ;
}
} ) ;
function view ( imgName) {
$( "#imgEdit" ) . show( ) ;
$( "#thumbnail" ) . attr( "src" , "http://quazza.com/uploads/" + imgName) ;
$( "#min_thumbnail" ) . attr( "src" , "http://quazza.com/uploads/" + imgName) ;
}
$( "#thumbnail" ) . imgAreaSelect( { aspectRatio: '1:1' , handles: true , fadeSpeed: 200, onSelectChange: preview} ) ;
function preview ( img, selection) {
if ( ! selection. width || ! selection. height)
return ;
var scaleX = thumbW / selection. width;
var scaleY = thumbH / selection. height;
$( "#min_thumbnail" ) . css( {
width: Math. round ( scaleX * widthImg) , height: Math. round ( scaleY * heightImg) , marginLeft: - Math. round ( scaleX * selection. x1) , marginTop: - Math. round ( scaleY * selection. y1) } ) ;
$( "#x1" ) . val( selection. x1) ;
$( "#y1" ) . val( selection. y1) ;
$( "#x2" ) . val( selection. x2) ;
$( "#y2" ) . val( selection. y2) ;
$( "#w" ) . val( selection. width) ;
$( "#h" ) . val( selection. height) ;
}
$( "#butSave" ) . click( function ( ) {
var x1 = $( "#x1" ) . val( ) ;
var y1 = $( "#y1" ) . val( ) ;
var x2 = $( "#x2" ) . val( ) ;
var y2 = $( "#y2" ) . val( ) ;
var w = $( "#w" ) . val( ) ;
var h = $( "#w" ) . val( ) ;
$. ajax ( {
url: "upload.php" ,
type: "POST" ,
data: { image: image, x1: x1, y1: y1, x2: x2, y2: y2, w: w, h: h} ,
success: function ( ) { newAvatar( image) ; }
} ) ;
function newAvatar ( avatar) {
$( "#thumbnail" ) . imgAreaSelect( { hide: true } ) ;
$( "#avatar" ) . html( "<img src=\" http://quazza.com/uploads/" + avatar+ "\" width=\" 200\" >" ) ;
$( "#minImg" ) . html( "<img src=\" http://quazza.com/uploads/min_" + avatar+ "\" >" ) ;
$( "#imgEdit" ) . hide( ) ;
}
} ) ;
} ) ;
</ script>
</ head>
< body>
< div id= "main" >
< div id= "wrapper" >
< div id= "content" >
< div id= "avatar" > Avatar</ div>
< div id= "minImg" ></ div>
< div style= "clear:both" ></ div>
< div id= "butUpload" >< span> To replace</ span>< img src= "/img/loading.gif" id= "imgLoad"
align= "right" /></ div>
< div id= "imgEdit" > < img src= "" style= "float: left; margin-right: 10px;" id= "thumbnail" />
< div id= "preview" style= "width: 100px; height: 100px; overflow: hidden;" > < img src= "" style= "width: 100px; height: 100px;" id= "min_thumbnail" /> </ div>
< br style= "clear:both;" />
< form name= "thumbnail" >
< input type= "hidden" name= "x1" value= "" id= "x1" />
< input type= "hidden" name= "y1" value= "" id= "y1" />
< input type= "hidden" name= "x2" value= "" id= "x2" />
< input type= "hidden" name= "y2" value= "" id= "y2" />
< input type= "hidden" name= "w" value= "" id= "w" />
< input type= "hidden" name= "h" value= "" id= "h" />
</ form>
< div id= "butSave" > Save</ div>
</ div>
</ div>
</ div>
</ div>
</ body>
</ html>
Страниц (2): [1] 2 »
Powered by ExBB FM 1.0 RC1. InvisionExBB