iMatch stored value with the current value in a loop
Posted on
16th Feb 2014 07:03 pm by
admin
Hello,
I have a MySQL db were I store articles in.
Did you know?Explore Trending and Topic pages for more stories like this.
I have a form to fill these articles, and in that form I can select images who are stored into a directory. Selecting the images works good but the problem is when I want to edit the stored article then the image is not saved and I again have to select it from the selectdropdown box. Basicly I want to match the stored value with the current value in my loop.
Is there a way that the earlier saved image into an article keeps up with the rest from the article but keep it dynamic so if I want to, I still van change the image easy.
My code:
<select name="content_img" id="content_img">
<option value="">
<?php
$dirPath = dir('media/images/content');
$imgArray = array();
while (($file = $dirPath->read()) !== false)
{
if ((substr($file, -3)=="gif") || (substr($file, -3)=="jpg") || (substr($file, -3)=="png"))
{
$imgArray[ ] = trim($file);
}
}
$dirPath->close();
sort($imgArray);
$c = count($imgArray);
for($i=0; $i<$c; $i++) {
$selected = (isset($image) && $image == $imgArray[$i]) ? "selected" : "";
echo "<option value='{$imgArray[$i]}' $selected>{$imgArray[$i]}</option>n";
}
?></option>
</select>
HELP...please
No comments posted yet
Your Answer:
Login to answer
344
17
Other forums
Email to a friend script problems
I have this send-to-a-friend script with 2 issues:
1) When you open the form popup on a p
php/mysql auto logout after 2 hour and reset password
Hi all,
This I hope will make sense. I've the following code which when a user logins in, cr
How can i steam a video on my PHP site? (non YouTube)
Basically I have a PHP site and don't want to give page rank to YouTube. I just want to stream a bas
rename the file
File.txt
Code: ***DOCUMENT***
..DN:
000044255
..CB:
..SN:
..PY:
2009
..E
Redirecting Admin
In my members table, I have a field called "perm" and it's set to zero for all members. Ho
OOP help
okay so i have a class im making it has everything setup i just need to randomize the 2 variables an
(sub)screen resize modification doesn't work after ECC 6 EhP 4 installation
Hello,
We have previously extended the size of the custom data tab on PO transaction ME23
SAP BCS. BPS
Hi all,
I am seeking reading note on the following in BW
BCS, BPS
ADVANCE
RadioButtonList item spacing
I have a RadioButtonList and I can't put any spacing between the items. They are arranged verticall
ALV List Display to point to another report on Double Click
Hi,
I want my ALV List Display to point to another report on Double Click on its line ite