Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Populating A Drop Down Via A File Directory?


I just wrote this code:

$dir = "/images/news";
print "<select name='file'>";
$dir = opendir($dir);
while (false !== ($file = readdir($dir))){
if (in_array($file, array(".", ".."))) continue;
print "<option value='$file'>$file</option>";
}
print "</select>";

But for some reason it is not populating. It instead echoes an empty drop down menu. Can anyone suggest anything?




View Complete Forum Thread with Replies

Related Forum Messages:
Drop Down Via A File Directory
I just wrote this code:

Code:
$dir = "/images/news";
print "<select name='file'>";
$dir = opendir($dir);
while (false !== ($file = readdir($dir))){
if (in_array($file, array(".", ".."))) continue;
print "<option value='$file'>$file</option>";
}
print "</select>";

View Replies !
Populating Drop Down
How do I do this drop down box ? Making an edit page. I have 2 tables

groups
id || categoryname

program

id || cateogry_id

I need to populate the groups in it at same time show the selected choice from program. Not showing id but needs to show categoryname with of course the values being the id of groups.

View Replies !
PHP + MYSQL, Populating Drop Down Box
I am looking to generate a dropdown box from MYSQL data:

db name = h2, table = Working, Column = Home.

View Replies !
Populating A Drop Down Menu
How would I go about populating a Drop Down menu from data in MySQL? If you can show me wither a URL to learn this, or if you feel like telling me here, that would be great.

View Replies !
Populating Drop Down And Table
I have a database with the following fields.
Name | Company | Date

values in each column could be repeated, or not. as in there could be several same names with the same company with different dates, or different names with same company.

How do I populate a table with this info and have drop down boxes, so that I can narrow down the search? For example:
Name | Company | Date
12     | 1           | 1929
13     | 1           | 1929
14     | 1           | 1929
12     | 2           | 1929
12     | 4           | 1929
13     | 1           | 1941
12     | 6           | 1929

So if in the drop down I select '12' under name, only those entries with 12 are shown, and then I can further sort it by selecting only '1' under Company.
Hope I'm clear, I manage to complicate things when I post them.

View Replies !
Auto Populating A Drop Down Box
Basically I'm setting up a website which needs an populated drop down box made up from all fields in a specific column of a table in a mysql db....

Here's the code I've made up using various tutorials....

<?php 
$user = "";  
$host = "" 
$password = "" 
$dbName =  "" 

/* make connection to database */  
mysql_connect($host, $user, $password) OR DIE( "Unable to connect 
to database"); 
mysql_select_db($dbName); //did you forget this line? 

$sql = "SELECT model FROM usedVehicles"; 
$query = mysql_query($sql) or die(mysql_error() . "<br>$sql"); //use the or die(...) part ONLY IN DEVELOPMENT 
?>

<form action="action" method="post"> 
<select name="option"> 

<?php  
while ($row = mysql_fetch_array($result)) {  
    echo "<option value="" . $row['model'] . "">" . $row['model'] . "</option>
";  
}  
?> 
</select> 
<input type="submit"> 
</form>

I've left out the connection details for obvious reasons... When I upload and try to test this, jus a blank drop down appears... there are definately fields in the column as I have tried the query on phpMyAdmin.

View Replies !
Populating A Drop Down List With Php
I am trying to get a drop down list to populate vbia php. What I have a is a script that allows a airline/user to enter airfare and price for tickets. It dumps them into a database and then allows the user to view/delete/add.

I want the user to be able to edit the airfare. I have a drop down list that is set as a variable $ticket_from, $ticket_to. The list contains around 400 cities. When the user clicks 'edit' I have the price population but no the drop down list. How do you go about something like that? I have this right now: Code:

View Replies !
Populating Drop Down Lists
Could anyone help me on populating database driven drop down menus. I am trying to populate a second drop down list based on the selection of the first drop down list. I have the first drop down list running. Not sure about getting the second now.

View Replies !
Populating Drop Down From A Query
I'm trying to populate a drop-down box from the results of a query. I end up with the first option coming through and then blanks in the rest. Something like this...

<option value=Acevedo>Acevedo</option>
<option value=></option>
<option value=></option>
<option value=></option>
<option value=></option> .......

View Replies !
Self Populating Drop Down Menus
i am trying to do is the following: I have a MySQL database that (very simplified) has a schema like this 'Students(Name, id, Course)' I would like to have a form on a web site that has 2 linked drop down menus, one 'Please select id' and one 'Please select course'. When a user of the site selects there Id from the first drop down menu, i want the second drop down menu to populate itself with the courses held in the database for the given users Id. I would like the first drop down menu to be populated from the database with a query similar to 'SELECT id FROM students'.

View Replies !
Populating Drop Down From MySQL
I am trying to populate a drop down menu of MySQL data using PHP and I have hit a snag. I think its probably something simple that a freah pair of eyes could pick out right away that I am just not seeing...

For some reason only the "firstname" part of the data is populating in the drop down and I can't figure out why. When I try to make changes to the echo lines to correct this, nothing shows up including the "firstname" data. Code:

View Replies !
Populating Drop Down Menu
I use the following code snippet to build a drop down menu with the
results of a query. How can I set the initial value of this input based
on the result of another query?

What I am trying to do is update records in the data base. The field
WkEndDate is pulled along with the rest of the record and the drop down
menu is built from a table of valid WkEndDate values. Code:

View Replies !
Populating Drop Down Fields
I am trying to populate a drop down menu with a mysql database. I was hoping to have a selection of months in the dropdown menu, based on date fields in my database when a user then selects a month, they will be brought to a new page that will have only the records created in that month. But in my database, the date is stored in this format: 2006-05-12 00:00:00 if you need to see my code, here it is:

<?
//database connection
$query = mysql_query("SELECT * FROM casinocredit");
// start to print out the form
echo "<form action="cats.php" method="POST"><select name="clients"><option value="" "selected">Select A Client</option>";
// loop through the records
while ($row = mysql_fetch_array($query))
{
echo "<option value="{$row['ID']}">{$row['ddate']}</option>";
}.........

View Replies !
Populating A Drop Down List With The Year
i'm trying to loop the years from 1960 - 2010 with the function get_year() below:
PHP Code:

View Replies !
Populating A Drop Box With Results From Database
I have a MySQL database with a table (category) with two fields, catId (int) and category (char(50)). What I want to do is to get all category names in this database and place all of them into a dropdown box on a web page so that the user can choose from the list of available categories.

View Replies !
Populating Drop Down Boxes From Database
I have two drop down boxes, the first one i am able to fill from my database using the following code. Code:

View Replies !
Populating A Drop Down From A MySQL Table
When they click submit, I want the name dropped from "invite" and added to a table "guests" with their answer if they are coming and how many. I know the SQL to make it happen, but I am pretty sketchy about the PHP. Code:

View Replies !
Auto Populating Multiple Drop Downs.
im trying to create two dropdowns, i need the first one to be the category and the second one to be the subcategory.  The category drop down autopopulates with the correct info from the database. and uses the table "category", the value of each drop down is represented by the "cat" field in the table (cat is basically and integer id number) and "Category" is used as what the user actually sees in the drop down (category is the actual word of the category).

Once the category is selected i would like to have the sub category auto populate with everything that has the same values as the selected category (cat)

Here is a break down of how the tables work.

Table 1 Name: "category"
Fields for Table 1:  "cat" (the id number), "category" ( the actual name of the category)

Table 2 Name: "subcategory"
Fields for Table 2: "cat" (corresponds with the cat id from table 1 to pull the correct data), "subc" (the basic id of the subcategory), "subcat" the actual name of the subcategory.

so the way i see it, have a normal drop down populated by a php query. then on change, populate subcategory drop down where cat = cat and display sub category.

View Replies !
Populating The Drop Down And Pressing The Submit Button
1. The first is I have two drop down menus. The first is "year" and the second is "mfr". When a user selects a year from the drop down it then populates the second drop down, mfr, from the MySQL database. Theat is working fine. But the problem I am having is the "submit" button (which I have labeled as "browse"). When I click it. Nothing happens, no action tacks place. I have looked over the code and I can't figure it out. (See Code Box 1 Below).

2. Right now the "mfr" drop down is populated by the MySQL database and reads with a list like "Acr", "Alp", etc. These are abreviations. I need to set up an array to have them instead read the entire mfr name. Example: Instead of "Acr" it needs to be "Acura". Instead of "Alp" it needs to be "Alpine". I need these full names to appear in the drop down. I know I need to do something like this (See Code Box 2 Below) but I can't get my finger on it. Code:

View Replies !
Populating Drop Down List With Selected Vaue
I have a drop down box and the "selected" value needs to be selected by a dynamic value that gets entered into the database, this is currently how im doing it: PHP Code:

<?php
                if($modify_row[21] == "0") {
                  print "<option value=" "></option>";
                  print "<option value="1">Active</option>";
                  print "<option value="0" selected>In-Active</option>";
                } elseif ($modify_row[21] == "1") {
                  print "<option value=" "></option>";
                  print "<option value="1" selected>Active</option>";

Its fairly straight forward, basically the option that is automatically selected needs to be the one coming from the database $modify_row[21].

View Replies !
Populating City,state,country Drop Down Menu
In the registration form I have city, state, country fields. I was
wondering if there was a database available on the net which has the
list of states in each of the countries. That way when a user selects
a country I could automatically populate the state drop down menu ...

View Replies !
Drop Down Menu Select And Populating Data Fields
I have a PHP/MySQL Content Management System set up for the job I work at. It's basically a shift program that lets users pick up shifts, post shifts, etc.

The data fields are tied to the shift ID which is selected from a dynamically populated drop down box. However, I cannot get the data fields to be updated when I select a new value and I cannot get the form to accept the new selected Shift ID. I have tried using JavaScript but cannot quite get it to work. Code:

View Replies !
Populating Multiple Drop Down Boxes From Mysql Table
Am having a problem with a dynamic, multiple drop down box query. If I run the code with only one select, it populates fine. If I run it with 2 selects then only the first drop down box populates - the second drop down box is empty. Am wondering if I need to put the query into an array and populate the boxes from there. Code:

View Replies !
PHP Upload Files Drop Into A Directory Based On The Name Chosen
I am using the existing upload script and would like to add the ability to have the files drop into a directory based on the name chosen from the drop down list on the form. Currently all files drop into the same directory all the user is notified via email. I want to keep the email notification ability. Code:

View Replies !
Populating Table With Text File
My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text file to populate a table.

I have a table named groups with two fields:
groups_idauto-increment primary
groups_name

So how do I create my text file to populate this table?

I'm going to use MS Notepad.

If it's set to auto-increment, do I need to include the number? If
so, does it start at 0 (zero)?

Would the file look like:

0,students
1,faculty
2, staff

or just

students
faculty
staff



View Replies !
Populating An Excel .csv File Rather As Well As MySQL
I am very new to this and have what may be a ridiculous question. Is there a way to have info populate both the MySQL table and an Excel .csv sheet? I know that I can go into PhpMyadmin and dump the data but this seems to be a bit cumbersome.

View Replies !
Include Or Require A File From A Protected Directory And Maintain The Directory's Access Control?
I have an htaccess protected directory and I'm accessing a file in it through a require "admin/admin.php"; command (admin being the protected directory). I was hoping for the username and password popup window, instead I got direct access to my file.

Is there another way to include or require a file from a protected directory and maintain the directory's access control??

View Replies !
How Can I Include A File Relative To The Top Level Directory From Any Other Directory ?
How can I include a file relative to the top level directory from any other
directory ?
I really hate to use absolut url or put all my files in one directory.

eg : include("<symbol for top>/somefile.php"); ?

View Replies !
File Upload :: Warning: Fopen - No Such File Or Directory
I’m getting the following errors when I try to run the script below on a live server. It’s a crude script which uploads text and images directly into MySQL. It works fine on my local machine, I have Apache, PHP4 and MySQL running on windows. The live server is Unix.

When I try to upload images from my loacal pc I get the error below, when I placed an image file within the same directory as the script on the live server and tried to upload it that worked. I wanted the script to allow image uplload from a client pc Can anyone offer a suggestion?

Warning: fopen("C:Apachehtdocs Grey.jpg", "r") - No such file or directory in /usr/local/home/httpd/vhtdocs/sitehostin/moondance/backend/test_imagedb.php on line 57
Code:

View Replies !
Php File To Call On A File In A Password Protected Directory
Does anyone know is I can have php file calling on a file in a password protected directory (through basic authentication)?

View Replies !
File Upload - Directory Is Writable, File Is Not
I'm writing a script to upload images along with articles to a
directory on the server. I'm developing it offline on my WinXP and
Apache 1.3.x laptop and it's working great, but when I move the script
to the server, I get write errors when the file attempts to upload.

So I set up a test script (included below) to test the directory
structures all the way up to the file, and every directory appears to
be writable, yet I can't write to the test file. I keep seeing
suggestions to set the open_basedir directive in the php.ini file to
solve this, but it's hasn't worked yet. Can anyone suggest what I can
try to get the uploads working?

<?php

$filename = 'images/articles/test.txt'
$somecontent = "Add this to the file";

......

View Replies !
Look In A File And See What The Name's Of The Files Are In There And Have Them Put In To A Drop Down Menu.
What i would like to do is look in a file and see what the name's of the files are in there and have them put in to a drop down menu. Dose some one know of a tutorial on this or how to do it?

View Replies !
File Upload By Drag & Drop
Can anybody tell me how to upload a file by dragging it onto a web
page? Using the <input = "file" .....> it is possible to upload files,
but files cannot be dragged onto web pages for uploading.. Any
suggestions? I found a few Java based stuff but none of them were free.

View Replies !
Remote File For A Drop-Down Menu
Im pretty new to PHP coding - and I'm not sure if this is enough to work with here. I've been working with a script that is used to search through member profiles. I need to add a drop-down field to the search form - but I'm not exactly sure what to do. An example of the current code ,that is used for a field similar to what I want to add, is this

$TXT[12] = file("".$VAR[5]."/inc/txt/country.txt"); $TXT[14] = "";
foreach ($TXT[12] as $TXT[13])
{ $TXT[13] = trim($TXT[13]); $SLT[4] = "";
if (isset($_GET['location'])) { if ($_GET['location'] == $TXT[13]) { $SLT[4] = " selected"; } }

Basically, all I understand, thus far, with this section of coding is where the file it is retrieving the drop-down information is located. I don't fully understand the use of the numbers in the $TXT commands.

View Replies !
MySQL - .SQL Drop File Is About 2.5gigs.
The .SQL drop file is about 2.5gigs. Doing a simple query:

select * from people where last_name like '%smith%'

A query like this can take up to two minutes. I've spent hours reading these forums and other sites on the internet, and I've figured that I need to do a couple things: create some indexes and possibly create some partitions One thing I couldn't figure out though is what order to do these things. Is creating partitions even necessary? Also, I tried creating indexes on first_name and last_name columns, and it seems like it's just freezing.

View Replies !
Drag And Drop File To Page View
I want to coding drag and drop but it has more problem. I wanna drag file from desktop and drop into page view then page view show description and file size, can I? Instead of browse from file by use button. How should I do about this?

View Replies !
Need To Create Drop Down Box With Data Pulled From Text File
Trying to make a drop down box like this example:

Dog
Cat
Bird

But sometimes I will need to update it...and add/remove names from the list. I want to do it fast and easy and I don't want to use a MySQL Database. I'd rather use a text file...can that be done? I would keep the info in a text file and then push it to a drop down box via php and html.

View Replies !
How Do I Change The Drop Down List So The Option Selected Last Time Is Then The Current One Shown In The Drop Down Box?
I have a drop down list with the town options 'Bury' and 'Ipswich' as
shown below.

When selecting one of the options, its value is passed to variable
$townsearch.

How do I change the drop down list so the option selected last time is
then the current one shown in the drop down box?

<body>

<?php $townsearch = $_get['town']; ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">

<select size="1" name="town">

<option>ipswich</option>
<option>bury</option>
&nbsp;
</select>&nbsp;

<input type="submit" value="GO" />

</form>

View Replies !
File Upload :: No Such File Or Directory In ..
I'm currently trying to get a file upload form to work, the original I started with came from this sites tutorial.. No matter what I tries, I gets messages like "Warning: Unable to create '/images/': No such file or directory in /Users/victor/Sites/foto/upfile.php on line 33"

/images has 777 properties. The form code is:

View Replies !
How To Get The File Permission Of A File And/or Directory?
How can I get the file permission of a file and/or directory? I am using a ftp_put function to copy a recursive directory over FTP to another server but need to preserve the file permissions.

View Replies !
Drop Down Lists Changing Depending On Other Drop Downs
I want to have a drop down system like this one.  But without the radio buttons.

I want to have 3 drop downs but have no idea how to go about it.  I assume I will need to activate some sort of Javascript on the onChange event of the option drop downs.

View Replies !
No Such File Or Directory
I have a php file checking a value in my database and opening one page if it is a 0 and another if it is a 1. My Problem is that the page returned when the value is a 0 is in the root directory while the php file is stored in a subfolder of another folder eg. "/test1/test/"

I thought this... include "../re_offer.htm"; Would let me view the file but i keep getting errors: Warning: main(../re_offer.htm): failed to open stream: No such file or directory in "blaa Blaa on line 39

View Replies !
File Directory
I was wondering whether anyone would know how to return a list of files in a directory in PHP? For example: I have a folder that I can upload images to, and rather than link to each one of them individually, or enter all the file names into a database, I would like to be able to go to a page that tells me the filenames of all the images I have just uploaded.

View Replies !
PHP File Directory
How to return a list of files in a directory in PHP? For example: I have a folder that I can upload images to, and rather than link to each one of them individually, or enter all the file names into a database, I would like to be able to go to a page that tells me the filenames of all the images I have just uploaded.

View Replies !
Using Php To Delete A File In A Directory- Help
I can use php to execute the cp command to copy an image file into a directory.

Now I want to delete images in that directory if they are not named "picturelink.gif" when an entry with a corresponding id is deleted.

Below is the code I am using which doesn't seem to be working when it comes to deleteing the file. The directory has the correct permissions for read/write access.

$query = "DELETE FROM $userstable WHERE id ='$id' ";

if($picture != "picturelink.gif")
{
exec("rm $picture /virtualhosts/capefearantiques.com/www/pictures/$picture");
}

View Replies !
Reading Only One File From Directory
I am trying to make a class that does a bunch of file stuff and one of the functions is suppose to read the files out of the directory. PHP Code:

View Replies !
How To Browse A Directory For A File?
I need to add a download function in a VB program, but since a file
can be located anywhere in our /download section on the web, I was
thinking of putting a PHP script there that would take the filename as
parameter, and browse through the /download directory to look for this
file, including sub-directories, and return the URL, ie.

View Replies !
Separate Php.ini File For Directory
I have some old legacy php scripts that need to run with register globals
on.

I would prefer not to run with register globals turned on where I don't need
to.

I am looking for a way of having a separate php.ini file for that directory,
that has globals on and run with globals off for the rest of my server.

View Replies !
Getting Last File From Linux Directory
I have been presented with the task of getting the last file from
a linux directory when the files are of the form:
nnnnnn-xxxxxxx-.ext

where nnnnnn are 6 numeric digits and xxxxxx is variable a/n data.

I could read the entire directory in an sort, but I hope there is
an easier way.

View Replies !
File And Directory Security
Context
-------
I'm building a very basic website, in php, to display a catalog of
jewel to be sold. The website have to basic functionality, one is the
consultation of the catalog and the other one is the maintenance of the
catalog. I have a MySQL ddatabase that contain the catalog, except the
images, which are keep in a directory.

website structure

.. PHP scripts to consult catalog.
..images Image of the catalog jewel.
..admin PHP scripts to maintain information. Password protected
directory.

I have a share hosting, the web-server run under Apache and I cannot
create new Apache user.

Problem
---------
I have one directory where I store all the image of the catalog. I need
to allow everybody to consult it in order to display the image, but
only authorized user should be able to create,update and delete images
in it.

View Replies !
File Listbox Of Directory
Is there anyway someone could provide code to a soultion i need here. Basically i have a directory of all these files uploaded, and i need some sort of way for a php file to list all the items in that directory somehow, it doesent need to be special, i just need them listed so my users can see what is uploaded into that directory.

View Replies !
Directory File Listing
Was wondering if anyone has already built something that can list all files and directories sub directories.. I can list files and directories, But im wanting to do it with a twist...

DIRA
--filename.txt
--filenameb.txt
DIRb
--something.jpg
--subDIR
----filename.txt

I would like to list them in some sort of tree view instead of listing the flat out... Any ideas? Or pre-written scripts?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved