Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 28. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Is there a way to display pictures in myphpedit?

phpMyEdit Features     Is there a way to display pictures in myphpedit?
Odoslať novú tému   Odpovedať na tému    
 
smokinpuppy     Založený: 26.03.2012   Príspevky: 14  
Príspevok Zaslal: 2012-03-28 19:29
Návrat hore  Odpovedať s citátom     

Hi,

I know its not a good idea to use blobs in mysql so now im saving a path in mysql table but im wondering if there is a away to have phpMyEdit show the image from the server in the table using the path instead of the actual binary data?

Thank you in advance,

Robert

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2012-03-29 15:24
Návrat hore  Odpovedať s citátom     

No image handling functions are built into phpMyEdit.

From an ancient project, I used this schema to save image details including the image type.

Kód:
CREATE TABLE IF NOT EXISTS `vs_inventory1` (
  `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
  `item_name` varchar(255) NOT NULL DEFAULT '',
  `item_category` varchar(25) NOT NULL DEFAULT '',
  `catid` smallint(5) unsigned NOT NULL DEFAULT '0',
  `item_sub_cat` varchar(25) NOT NULL DEFAULT '',
  `scatid` smallint(5) unsigned NOT NULL DEFAULT '0',
  `item_number` varchar(20) NOT NULL DEFAULT '',
  `item_description` text NOT NULL,
  `on0` varchar(25) NOT NULL DEFAULT '',
  `os0` varchar(255) NOT NULL DEFAULT '',
  `on1` varchar(25) NOT NULL DEFAULT '',
  `os1` varchar(255) NOT NULL DEFAULT '',
  `amount` float(10,2) NOT NULL DEFAULT '0.00',
  `weight` float(8,2) unsigned NOT NULL DEFAULT '0.00',
  `shipping1` float(8,2) NOT NULL DEFAULT '0.00',
  `shipping2` float(8,2) NOT NULL DEFAULT '0.00',
  `tax` float(6,2) NOT NULL DEFAULT '0.00',
  `taxable` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `addx` smallint(5) unsigned NOT NULL DEFAULT '1',
  `currency_code` varchar(8) NOT NULL DEFAULT 'USD',
  `image` mediumblob NOT NULL,
  `image_width` smallint(5) unsigned NOT NULL DEFAULT '0',
  `image_height` smallint(5) unsigned NOT NULL DEFAULT '0',
  `image_type1` tinyint(2) unsigned NOT NULL DEFAULT '0',
  `image_type2` varchar(20) NOT NULL DEFAULT '',
  `img_attrib` varchar(30) NOT NULL DEFAULT '',
  `hidden` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `item_number_2` (`item_number`),
  KEY `catid` (`catid`),
  KEY `scatid` (`scatid`),
  KEY `item_name` (`item_name`)
) ENGINE=MyISAM;


A regular PHP script was used to grab the image:
Kód:

<?php

// getimage.php

$id = array_key_exists('id', @$_GET) ? @$_GET['id'] : '';

if(is_numeric($id)){

   $data = '';

   $type = '';

   // add your database connection here

   $res  = @mysql_query('SELECT image, image_type2 FROM vs_inventory1 WHERE id = '.$id);

   $data = @mysql_result($res, 0, 'image');

   $type = @mysql_result($res, 0, 'image_type2');

   @header("Content-type: $type");

   echo $data;

}

?>


The PHP/HTML code used to fetch the image is:

Kód:
<img src="getimage.php?id=<?php echo $id; ?>" alt="<?php echo htmlspecialchars($item_name); ?>" border="0" <?php echo $img_attrib; ?>>


Storing images in MySQL is (IMHO) a huge waste of time, very inefficient, especially if recalling more than one image on a page due to multiple db connections having to be made.

http://www.hockinson.com/photo-gallery-example/

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2012-03-29 15:30
Návrat hore  Odpovedať s citátom     

Search the forum for CONCAT

With path information stored in the db, examples can be found for creating custom HTML tags for A tags, IMG tags, etc., using the MySQL CONCAT function.

Kód:
$opts['fdd']['dummy2'] = array (
   'name' => 'Thumbnail',
   'sql|VLF' => 'if(category = "other",
      CONCAT("<a href=\"", dir, "/", filename, "\" target=\"_blank\">link</a>"),
         if(category = "thumb", CONCAT("<a rel=\"example_group\" href=\"", REPLACE(dir, "/tn", "/"), filename, "\" target=\"_blank\"><img src=\"", dir, "/", filename, "\" ", " alt=\"\" border=\"0\"></a><br><a href=\"fancybox.change.php?upld_id=", upld_id, "\">Replace</a>"), ""))',
   'options'  => 'VLF',
   'input'  => 'R',
   'escape' => false,
   'sort'     => false
);


Kód:
$opts['fdd']['virtual_field'] = array (
   'name' => 'Thumbnail',
   'sql|VLF' => 'if(mime_type = "image/jpeg", CONCAT("<a rel=\"example_group\" href=\"", REPLACE(dir, "/tn", "/"), filename, "\" title=\"", text_1, "\" target=\"_blank\"><img src=\"", dir, "/", filename, "\" ", " alt=\"\"></a>"), "")',
   'options'  => 'VLF',
   'input'  => 'R',
   'escape' => false,
   'sort'     => false
);


 
smokinpuppy     Založený: 26.03.2012   Príspevky: 14  
Príspevok Zaslal: 2012-03-30 00:17
Návrat hore  Odpovedať s citátom     

Hi I'm trying to use the path (ex. Pictures/file.jpg) in another column to show the image in the next column in the row like a thumbnail. I tried the Coe before but it didn't work. Also I'm trying to put the picture which is actually in a folder with the phpMyEdit file. Thanks,

Robert

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2012-03-30 05:50
Návrat hore  Odpovedať s citátom     

"Pictures/file.jpg" is data in a database table, right?

 
smokinpuppy     Založený: 26.03.2012   Príspevky: 14  
Príspevok Zaslal: 2012-03-30 11:18
Návrat hore  Odpovedať s citátom     

Yes, that's right

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2012-03-30 17:30
Návrat hore  Odpovedať s citátom     

Adding one of these to the field array for your_field_name should work, i.e. use the second one (with ../) if the Pictures folder is one directory level above the phpMyEdit script.

Kód:
'sql|VLF' => 'if(your_field_name <> "", CONCAT("<img src=\"", your_field_name, "\" ", " alt=\"\">"), "")',

'sql|VLF' => 'if(your_field_name <> "", CONCAT("<img src=\"../", your_field_name, "\" ", " alt=\"\">"), "")',


 
smokinpuppy     Založený: 26.03.2012   Príspevky: 14  
Príspevok Zaslal: 2012-03-30 18:25
Návrat hore  Odpovedať s citátom     

Thank you very much, it worked, and looks great :)

Just for reference I also added height and border so it would fit nicely in the column. Ended up like this:

'sql|VLF' => 'if(Filename <> "", CONCAT("<img src=\"", Filename, "\" ", " alt=\"\"height=75 border=0>"), "")',

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov