Ordovicium
Joined: 24 Jun 2005
Posts: 1
Posted: 2005-06-24 18:31
Back to top
Reply with quote
|
Ok, I have my directory stored in my database. Looks like "/images/quotes/mensjournal.gif"
To display it in the table as a image do following:
Add at the top, right after <?php this block:
| Code: |
// get list of images
$imageArray = array("" => "");
$imagepath = "../images/";
$dh = opendir($_SERVER["DOCUMENT_ROOT"] . $imagepath);
while(($image = readdir($dh)) !== false) {
if (!preg_match("/^\.\.?/", $image)) {
$imageArray[$imagepath . $image] = $image;
}
}
ksort($imageArray);
reset($imageArray);
|
Then go to the table where you wanna let it appear. search in this block for
and replace it with
| Code: |
'sort' => true,
"sql|LF" => "CONCAT('<img src=\"..', image, '\" border=0 height=100 width=100><br />', image)",
"values2" => $imageArray,
"escape" => false |
Works fine for me.
|
Shaba1
Joined: 27 Sep 2005
Posts: 11
Posted: 2005-09-30 20:31
Back to top
Reply with quote
|
| Ordovicium wrote: |
Ok, I have my directory stored in my database. Looks like "/images/quotes/mensjournal.gif"
To display it in the table as a image do following:
Add at the top, right after <?php this block:
| Code: |
// get list of images
$imageArray = array("" => "");
$imagepath = "../images/";
$dh = opendir($_SERVER["DOCUMENT_ROOT"] . $imagepath);
while(($image = readdir($dh)) !== false) {
if (!preg_match("/^\.\.?/", $image)) {
$imageArray[$imagepath . $image] = $image;
}
}
ksort($imageArray);
reset($imageArray);
|
Then go to the table where you wanna let it appear. search in this block for
and replace it with
| Code: |
'sort' => true,
"sql|LF" => "CONCAT('<img src=\"..', image, '\" border=0 height=100 width=100><br />', image)",
"values2" => $imageArray,
"escape" => false |
Works fine for me. |
Ovodicdum: if you are still on this forum I had some questions about the code you posted. Specifically.
What does thist statment do -->"sql|LF". Or where is it in the phpmyedit manual?
=> "CONCAT('<img src=\"..', image, '\" border=0 height=100 width=100><br />', image)",
Here I think you are printing html code out to the page that is being displayed to the user. But why do you have 'image' after the src=' statement. What exactly does CONCAT do?
I will try to look up the follow two statements in teh manual
"values2" => $imageArray,
"escape" => false
Thanks
|
coach
Joined: 21 Oct 2005
Posts: 6
Posted: 2005-10-31 19:15
Back to top
Reply with quote
|
Hi,
I made a small enhancement to avoid "empty" images
| Code: |
'sql|LF' => "IF(image = '', NULL, CONCAT('<img src=\"', image, '\" border=0 height=100 width=100><br />', image))",
|
Coach
|
Shaba1
Joined: 27 Sep 2005
Posts: 11
Posted: 2005-11-02 21:03
Back to top
Reply with quote
|
Thanks coach. But my real question was about
#1.The use of "image" without the $ in the CONCAT() statement. I know that one could use $image to get php to put the name and path of the image into the CONCAT() statement but it look like the original poster just uses the string "image" That would not seem right to me. Maybe I am missing something?
and:
#2 The use of the "sql |LF" statment. I have read in the manual about the 'sql" and the "sqlw" arrays but nowhere that I can fine does it say that it can be combined with a vertical bar and any of the "adpvlf" field options. Maybe something else I am missing.
| coach wrote: |
Hi,
I made a small enhancement to avoid "empty" images
| Code: |
'sql|LF' => "IF(image = '', NULL, CONCAT('<img src=\"', image, '\" border=0 height=100 width=100><br />', image))",
|
Coach |
|
coach
Joined: 21 Oct 2005
Posts: 6
Posted: 2005-11-07 17:45
Back to top
Reply with quote
|
Hi Shaba,
| Shaba1 wrote: |
| #1.The use of "image" without the $ in the CONCAT() statement. I know that one could use $image to get php to put the name and path of the image into the CONCAT() statement but it look like the original poster just uses the string "image" That would not seem right to me. Maybe I am missing something? |
image is the name of the column in the database.
| Shaba1 wrote: |
| #2 The use of the "sql |LF" statment. |
I don't know but it's working.
Coach
|
aeiche
Joined: 06 Apr 2007
Posts: 10
Posted: 2007-05-08 19:17
Back to top
Reply with quote
|
| Shaba1 wrote: |
Thanks coach. But my real question was about
#2 The use of the "sql |LF" statment. I have read in the manual about the 'sql" and the "sqlw" arrays but nowhere that I can fine does it say that it can be combined with a vertical bar and any of the "adpvlf" field options. Maybe something else I am missing.
|
The pipe or vertical bar applies the SQL or SQL only to those specific options. It's the last item in the field options section of the documentation:
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.options-variability.html
|
gb5256
Joined: 30 Aug 2008
Posts: 7
Posted: 2008-09-03 21:30
Back to top
Reply with quote
|
Hello,
great work to everybody involved !!!
I have used the code above and added the URL functions as I would like to make the picture clickable.
Here is my code:
| Code: |
$opts['fdd']['images'] = array(
'name' => 'Fotos',
'select' => 'T',
'maxlen' => 10,
'sort' => true,
"sql|LF" => "IF(images = '', NULL, CONCAT('<img src=\"images_proben/', images, '\" border=0 height=20 width=20><br />', images))",
"values2" => $imageArray,
"escape" => false,
'URLprefix' => 'http://webxxxxxx/images_proben/',
'URL' => $value
); |
The problem is, that the link is like this:
| Code: |
| http://webxxxxxxxxxx/images_proben/%3Cimg%20src=%22images_proben/1.jpg%22%20border=0%20height=20%20width=20%3E%3Cbr%20/%3E1.jpg |
So it used as a value the HTML used for displaying the image. Can I overwrite that somehow?
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2008-09-04 12:54
Back to top
Reply with quote
|
Don't use the URL functions with SQL - they clash. Use the CONCAT function in the SQL line to build the complete correct URL as you want to see it.
|
gb5256
Joined: 30 Aug 2008
Posts: 7
Posted: 2008-09-04 19:20
Back to top
Reply with quote
|
Can I use the SQL command twice within the same block?
|
ajh
Joined: 17 Dec 2003
Posts: 236
Posted: 2008-09-08 09:40
Back to top
Reply with quote
|
No...but you shouldn't need to. You should be able to construct an SQL statement that does anything you want for one transaction. If you need to do multiple transactions (ie post something to another table), then you need to look at triggers.
|
|
Post new topic
Reply to topic
|