Jump to content

streamland

Members
  • Posts

    17
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

streamland's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. but why this code doesn't work on IE 8 meaning doesn't upload image but on Chrome works fine
  2. I think sniperscopefeels difficult with his english and like to say What i want is list today's worker after 10pm and include everybody who will work tomorrow. and I need to display staff_id who will work today and after 5pm and the same way tomorow.
  3. Is it a deliberate obfuscation ploy of yours to to put the mark value in $model and the model value in $mark? All your queries seem to have it like that. Yes ...
  4. $where = array(); $whereclause = ''; if (!empty($mark)) { $where[] = "a.mark = '$model'"; } if (!empty($model)) { $where[] = "a.model = '$mark'"; } if (!empty($year)) { $where[] = "a.year = $year"; } if (count($where > 0)) { $whereclause = join(' AND ', $where); } $result = mysql_query("SELECT * FROM `add_new_car` AS a INNER JOIN `image_add_car` AS b ON a.id_add_car = b.user_id WHERE (b.user_id, b.id_image_add_car) IN (SELECT user_id, MIN(id_image_add_car) FROM image_add_car GROUP BY user_id) AND $whereclause ORDER BY a.id_add_car"); Barand Mark=toyota Model=Prado Year=2013 But why when I chose just Mark it doesn't gives any result but both together with Model=Prado it works fine
  5. that was my carelessness the query from you worked fine thank you SELECT * FROM `add_new_car` AS a INNER JOIN `image_add_car` AS b ON a.id_add_car = b.user_id WHERE a.mark='$mark' and a.model='$model' and a.year='$year' GROUP BY a.id_add_car now will check WHERE clause :-)
  6. Barand sorry but this query doesn't work it returs no result SELECT * FROM `add_new_car` AS a INNER JOIN `image_add_car` AS b ON a.id_add_car = b.user_id WHERE a.mark='$mark' and a.model='$model' and a.year='$year' GROUP BY a.id_add_car anyway the first query worked fine for me. But I've got another question, what if some one will not select or select just a.mark='$mark' should I use IF Statment to build a few query for example like if empty($model)& empty($year) SELECT * FROM `add_new_car` AS a INNER JOIN `image_add_car` AS b ON a.id_add_car = b.user_id WHERE (b.user_id, b.id_image_add_car) IN (SELECT user_id, MIN(id_image_add_car) FROM image_add_car GROUP BY user_id) AND a.mark='$mark' ORDER BY a.id_add_car Thank you!
  7. SELECT * FROM `add_new_car` AS a INNER JOIN `image_add_car` AS b ON a.id_add_car = b.user_id WHERE (b.user_id, b.id_image_add_car) IN (SELECT user_id, MIN(id_image_add_car) FROM image_add_car GROUP BY user_id) AND a.mark='$model' and a.model='$mark' and a.year='$year' ORDER BY a.id_add_car Thank you so much brand I Could get something like this and will test it
  8. The first picture is date table (add_table) second table (image_path_table) here I keep images path Please help built the query to select date from (add_table) and path to picture from (image_path_table) $result = mysql_query("SELECT * FROM `add_new_car` AS a INNER JOIN `image_add_car` AS b ON a.id_add_car = b.user_id WHERE a.id_add_car =b.user_id and a.mark='$model' and a.model='$mark' and a.year='$year' ORDER BY a.id_add_car"); thank you
  9. The code works fine untill I am adding thambnail code $query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ') VALUES ("' . implode('", "', $data) . '")'; This gives me something like this (image1,image2,image3,image4,image5,image6) values (23423423-1.jpeg,32423423-2.jpeg,9798796-3.jpeg,123123123-4.jpeg,2342342323-5.jpeg,23423423-6.jpeg) and it locate the image the way I need. I just need to implement the thambnail code and trying to built something like this (image1,image2,image3,image4,image5,image6,imagesm1,imagesm2,imagesm3,imagesm4,imagesm5,imagesm6) $query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ' , ' . implode(', ', $cols_sm) . ') VALUES (' . implode(', ', $data) . ' , ' . implode(', ', $data_sm) . ')'; Thank you for given info but I'd like to finish this code.
  10. I appreciate for help I could get it work. The path goes to db and the I can weiw it. But also I'd like by the way thambnail the images and locate path the same way . image1 image2 image3 image4 image5 image6 image_small1 image_small2 image_small3 image_small4 image_small5 image_small6 I've got the thambnail script which I would like to implement here Could you please help me do it $i = 1; $sm = 1; $images_sm = "thumbnails_"$uploadFilename[$key]; // now let's move the file to its final and allocate it with the new filename foreach($active_keys as $key) { @move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key],$uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $cols[] = "image" . $i++; //<-- note that I removed the comma $cols_sm[] = "image_small" . $sm++;[/background][/size][/font][/color] [color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif][size=3][background=rgb(250, 250, 250)] $data[] = "'" . basename($uploadFilename[$key]) . "'"; //----------------------------------------------------------------------------------------------------- $width=100; //*** Fix Width & Heigh (Autu caculate) ***// //$size=GetimageSize($images); $size=GetimageSize($uploadFilename[$key]); $height=round($width*$size[1]/$size[0]); $images_orig = ImageCreateFromJPEG($uploadFilename[$key]); $photoX = ImagesX($images_orig); // получаем ширину $photoY = ImagesY($images_orig); // а здесь высоту $images_fin = ImageCreateTrueColor($width, $height); ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY); ImageJPEG($images_fin,"uploaded_files/".$images_sm); ImageDestroy($images_orig); ImageDestroy($images_fin); // -------------------------------------------------------------------------------------------------------------- $data_sm[] = "'" . basename($uploadFilename[$key]) . "'"; } $query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ' , ' . implode(', ', $cols_sm) . ') [/background][/size][/font][/color] [color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif][size=3][background=rgb(250, 250, 250)] VALUES (' . implode(', ', $data) . ' , ' . implode(', ', $data_sm) . ')';
  11. <?php // filename: upload.processor.php // first let's set some variables include("conf.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); //$db = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // make a note of the current working directory, relative to root. $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']); // make a note of the directory that will recieve the uploaded files $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploaded_files/'; // make a note of the location of the upload form in case we need it $uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'multiple.upload.form.php'; // make a note of the location of the success page $uploadSuccess = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'multiple.upload.success.php'; // name of the fieldname used for the file in the HTML form $fieldname = 'file'; //echo'<pre>';print_r($_FILES);exit; // Now let's deal with the uploaded files // possible PHP upload errors $errors = array(1 => 'php.ini max file size exceeded', 2 => 'html form max file size exceeded', 3 => 'file upload was only partial', 4 => 'no file was attached'); // check the upload form was actually submitted else print form isset($_POST['submit']) or error('the upload form is neaded', $uploadForm); // check if any files were uploaded and if // so store the active $_FILES array keys $active_keys = array(); foreach($_FILES[$fieldname]['name'] as $key => $filename) { if(!empty($filename)) { $active_keys[] = $key; } } // check at least one file was uploaded count($active_keys) or error('No files were uploaded', $uploadForm); // check for standard uploading errors foreach($active_keys as $key) { ($_FILES[$fieldname]['error'][$key] == 0) or error($_FILES[$fieldname]['tmp_name'][$key].': '.$errors[$_FILES[$fieldname]['error'][$key]], $uploadForm); } // check that the file we are working on really was an HTTP upload foreach($active_keys as $key) { @is_uploaded_file($_FILES[$fieldname]['tmp_name'][$key]) or error($_FILES[$fieldname]['tmp_name'][$key].' not an HTTP upload', $uploadForm); } // validation... since this is an image upload script we // should run a check to make sure the upload is an image foreach($active_keys as $key) { @getimagesize($_FILES[$fieldname]['tmp_name'][$key]) or error($_FILES[$fieldname]['tmp_name'][$key].' not an image', $uploadForm); } // make a unique filename for the uploaded file and check it is // not taken... if it is keep trying until we find a vacant one foreach($active_keys as $key) { $now = time(); while(file_exists($uploadFilename[$key] = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name'][$key])) { $now++; } } $i = 1; $cols = array(); $data = array(); // now let's move the file to its final and allocate it with the new filename foreach($active_keys as $key) { @move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $cols[] = "image" . $i++; //<-- note that I removed the comma $data[] = basename($uploadFilename[$key]); //<-- note that I removed the quotes } $cols = array_map ('mysql_real_escape_string', $cols); $data= array_map ('mysql_real_escape_string', $data); $query = 'INSERT INTO `imloop` (' . implode(', ', $cols) . ') VALUES ("' . implode('", "', $data) . '")'; //$strSQL .="(Thumbnails,FilesName) VALUES ('".$new_images."','".$image_name[$i]."')"; mysql_query($query) or exit($query . '<br />' . mysql_error()); // If you got this far, everything has worked and the file has been successfully saved. // We are now going to redirect the client to the success page. header('Location: ' . $uploadSuccess); mysql_close($connection); // make an error handler which will be used if the upload fails function error($error, $location, $seconds = 5) { header("Refresh: $seconds; URL=\"$location\""); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n". '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n". '<html lang="en">'."\n". ' <head>'."\n". ' <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n". ' <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n". ' <title>Upload error</title>'."\n\n". ' </head>'."\n\n". ' <body>'."\n\n". ' <div id="Upload">'."\n\n". ' <h1>Upload failure</h1>'."\n\n". ' <p>An error has occured: '."\n\n". ' <span class="red">' . $error . '...</span>'."\n\n". ' The upload form is reloading</p>'."\n\n". ' </div>'."\n\n". '</html>'; exit; } // end error handler ?>
  12. Yeh I have tested it and it locate image (to db) as I needed but the problem is now shown bellow : INSERT INTO `imloop` (`id`, `image1`, `image2`, `image3`, `image4`, `image5`, `image6`) VALUES (1, '1352903903-1.jpg', 1352903903, 1352903903, 1352903903, 1352903903, 1352903903); or INSERT INTO `imloop` (`id`, `image1`, `image2`, `image3`, `image4`, `image5`, `image6`) VALUES (1, '1352903903-1.jpg', 1352903903, 1352903903, 1352903903, 1352903903, 1352903903), (2, '1352904073-6.jpg', 1352904073, 0, 0, 0, 0), (3, '1352904279-1.jpg', 1352904279, 1352904279, 0, 0, 0), (4, '1352904587-1.jpg', 1352904587, 1352904587, 0, 0, 0); why it locate just first image I am putting in and repeat it to the `image2`, `image3`, `image4`, `image5`, `image6` . and doesn't show others I am adding.
  13. Thank you I will test it now !
  14. Having some change like bellow it gives me an error INSERT INTO `imloop` ( image1, image2, image3, image4, image5, image6) VALUES (" \'1352838703-1.jpg\', \'1352838703-2.jpg\', \'1352838703-4.jpg\', \'1352838703-5.jpg\', \'1352838703-6.jpg\', \'1352838703-5.jpg\'") Column count doesn't match value count at row 1 $i=1; // now let's move the file to its final and allocate it with the new filename foreach($active_keys as $key) { @move_uploaded_file($_FILES[$fieldname]['tmp_name'][$key], $uploadFilename[$key]) or error('receiving directory insuffiecient permission', $uploadForm); $query_part_1 .= " image" . $i++ . ","; $query_part_2 .= " '" . basename($uploadFilename[$key]). "',"; } $query_part_1 = preg_replace("/,$/","",$query_part_1); // remove the comma at the end of the string $query_part_2 = preg_replace("/,$/","",$query_part_2); $cols[] = $query_part_1; $data[] = $query_part_2; $cols = array_map ('mysql_real_escape_string', $cols); $data= array_map ('mysql_real_escape_string', $data); $query = 'INSERT INTO `imloop` (' . implode(',', $cols) . ') VALUES ("' . implode('","', $data) . '")'; mysql_query($query) or exit($query . '<br />' . mysql_error()); CREATE TABLE IF NOT EXISTS `imloop` ( `id` int(10) NOT NULL AUTO_INCREMENT, `image1` varchar(255) DEFAULT NULL, `image2` int(255) NOT NULL, `image3` int(11) NOT NULL, `image4` int(11) NOT NULL, `image5` int(11) NOT NULL, `image6` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=38 ;
  15. I just simple like to arange pic like bellow id image1 image2 image3 image4 image5 image6 1 pic1 pic2 pic2 pic2 pic2 pic2 2
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.