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
Putting double spaces instead of single spaces
Im looking at trying to replace all single spacing between fields with double spacing
At pres
Problem in String replace program's output
Hi all,
I was trying to make a program which accepts a string and replaces it with another stri
Collecting AOL Search Terms
I am attempting to collect AOL search terms. I know the code is correct (it works for google, bing,
Error Messaging not working
I changed the way my form tells the user of an error. But I can't seem to get it to work properly.
The repetition structure: the while statement not working
New programming student, have assignment as follows:
A restaurant has 4 lunch combos for custom
Renaming a file that a user uploads to site?
My site allows for registered users to upload images to the site under their own gallery. Currently
Need a Timecode Class...
Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont re
Escape Latin Characters
I need to escape latin characters in an xml doc. Example: "é" is escaped to "é". I thoug
image upload script not working with png
The basic process of this php code is to take the submitted file, convert it to a small JPG thumbnai
Map.php
I am a complete beginner to PHP and am looking for some help with a program I am messing around with