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.
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
grouping within a foreach?
hello all,
I currently have a list of products spit out from my db via a foreach loop. Right
no idea what to do...
I'm fed up. I had issues with code that I have working on a different site that didn't work on my cu
reading xml faster than DB call?
I am trying to optimize a high traffic website, and I enabled a feature where there are three photos
Update Database
Hi All,
I have a problem with this:
Code: [Select]<?php
session_start();
SESSION CHECK WORKS "MOST" of the time... whats going on?
i have a sign in check thats included in every page that is a members only page which is basically a
Pagination
Okay here is the page in question: http://blenderteachings.000a.biz/tutorials.hamishhill.php
Get relative path from absolute path
How would one go about getting the relative path to a file from its absolute path?
Alterar a hora do servidor
Se alguém souber, ajude-me a adicionar 6 horas, obrigado
<tr>
&
Schedule editor
Hi,
I have a question related to Schedule editor.
If we schedule a BLS for every 30
help removing unwanted graphic
How do I remove the small elongated rectangular shape between the "Latest post" and "