Please bear with me as I am very new to php and html.
I have a form with several drop down menus, the one at the top shows a list that when an item is selected fills in the form below including the other drop downs. So when an item is selected the form gets info from a mysql database and then fills in the form. At this point the user can further modify the form and re-submit it to update the database. This means that the drop downs in the form not only need to display the relavent options from the database to reflect the existing choice but also when clicked on show a list to allow the user the change the selection from the list.
This means that the dropdown needs to:
show the words 'select item' when the form is first loaded and the form is empty
show the current selection when the defined by a selection in the top drodown
show all the available items when the list is dropped down
Curently my drop down does only this:
shows the nothing when the form is first loaded and the form is empty
shows the current selection when defined by a selection in the top drodown
show all the available items when the list is dropped down plus the one that was there before it was clicked on, therefore doubing the option up showing the same option twice
The form is here if you would like to see it in action: http://www.spencercarpenter.co.uk/portfolioAppFiles/simpleForm.php
And a snippet of code from one of th drop downs is here:
Code: <select name="img01" onChange="updateImg(this, 'thumbImg01')">
<option value=-"-1" ><?php echo $row_chosen_pItem['img01']; ?></option>
<?php buildFileList5('uploaded');?>
</select>
the code inside the 'buildFileList5' looks like this:
Code: <?php
function buildFileList5($theFolder)
{
// Execute code if the folder can be opened, or fail silently
if ($contents = @ scandir($theFolder))
{
// initialize an array for matching files
$found = array();
// Create an array of file types
$fileTypes = array('jpg','jpeg','gif','png');
// Traverse the folder, and add filename to $found array if type matches
$found = array();
foreach ($contents as $item)
{
$fileInfo = pathinfo($item);
if (array_key_exists('extension', $fileInfo) && in_array($fileInfo['extension'],$fileTypes))
{
$found[] = $item;
}
}
// Check the $found array is not empty
if ($found)
{
// Sort in natural, case-insensitive order, and populate menu
natcasesort($found);
$selectedImage = ""; //default image
foreach ($found as $filename)
{
if(!empty($_POST['img01']) && $_POST['img01'] == $filename)
{
$sel = "SELECTED";
$selectedImage = $filename;
}
echo "<option value='$filename' $sel>$filename</option>n";
}
}
}
}
?>
I hope that is enough info to explain it.
If anyone could tell how to get the dropdown working properly I would be very gratefull.
Thanks a lot
am I using this for loop correctly
Dear buddies!
Certain files upload, while others do not
I want to read the data from an uploaded file. Not sure why, but it only uploads for certain files. Not sure if it has to do with the size or what. Even when I comment all of the if and else
How would I do "Users not logged in since *** delete them"
I know how I would set this up, and delete the user roughly.I'll create a table called "Users Status" with ID, Username, date registered, and last logged in collumns. Last Logged in will be
frames get header location..
i have two frames, one top, one bottom. how do i do a form on the bottom frame that gives me the url of the top frame.is it get header location?.. if so how do i use it to get the top frames url.is
help with mysql_error()
Hi,I am trying to insert data into a table, but I am not able to insert it. I wanted to see what the error was using mysql_error() function, but it does not return any error string for me. I have
Simpler method of getting variables from mysql
Hi Guys,I'm trying to streamline my CMS's code and as I was writing a new page it occured to me that there might be an easier way to get variables from a mysql query and that if anyone knew how to do
Multi dimensional arrays
If I put in this code:
Problem writing URL into database
How would I write this into the database?<?php echo "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; ?>I tried this:Code: $url =
Create or replace package is ending ORA-21700
Database 9.2.0., patch 8 (9.2.0.8.0).
blank page.... nothing is happening.
I'm new to a lot of this but in the last 24hrs have learned a lot.Installed latest version of mysql... went fine no problems.Installed latest version of php... went fine no problems.did all my