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.





Read A Directory Files, And Create Echo HTML?


i have a foo/ directory and a foobar/ directory, and a barfoo/ directory in root/

for each directory in root, i'll put x or y or z amount of images in each directory. then, have the php write 01.html with the correct links to a) main image, b) thumb images and prev/fwd links.

we could have separate php files to handle the drawing of the new sequenced .html files in each directory (probably best to pass variables), because they're slightly different, or one to rule them all (sounds like too much work).

then, the syntax would need to be sorted out (so index.html has a link to foo/foo.php?=foo01) would work correctly and draw up 01.html with the correct images, being that index.html would probably have to have hardcoded variable-passing links. eh?

it's sweet, 'cause updating would be fast. upload and delete image files. done. I mean, I know that you could go the database/XML route, but sigh ........




View Complete Forum Thread with Replies

Related Forum Messages:
Read All Files From A Directory?
how to read all files from a directory and put them in a table?

View Replies !
Lists The Files In A Directory Echo Names Without Extension
I have an open directory document which lists the files in a directory. Is there any way to echo the name without the extension.


$dir = $_GET['artist'];
if ($handle = opendir($dir)) {
while ($file = readdir($handle)){
if ($file != '.' && $file != '..' && $file != 'info.txt'){
echo "<a href ="$dir/$file">".$file."</a>";
}
}
closedir($handle);
}

View Replies !
How Can I Display The Result Of The Array Of Files I Have Read From A Directory.
how can I display the result of the array of files I have read from a directory. I know How to read from a directory but I am wondering how to diplay the result in a table with, let's say, rows of 5 images. What would happen if I don't have enough of file to make a row ?

View Replies !
Read Contents Of Directory - If Not Text Files Exit
I have to make a page that shows the contents of a directory BUT if there are no text files in the folder I am supposed to kill the script. Code I tried (for that specific part of the script) was: Code:

$directory = dir("./courses/");
if(!(isset($directory[2]))){
die("No files in directory");
}

To my knowledge $directory[0] would be taken up by "." and [1] would have ".." so I thought if [2] isn't set then there isnt an actual file in the directory. I am sure there must be a better way of doing this however as [2] could easily be taken up by a folder or image and still come out true that there is a txt file.

View Replies !
Passing Variable - Make Read A Two Files, And Create A New File
I have a small script with a form, and if the form is submited (goes back to the same script) that it will make read a two files, and create a new file, and move it to a different directory. Everything works except, I'm trying to change one part. When I insert

$header3 = "<?php $title = $header ?>";

Then I add that to another variable
$data = "$header3
$top
$header2
$info2
$bot
";

Then I write that to the file via:
if (!$file_handle = fopen($filename,"w+")) { echo "Cannot open file"; }
if (!fwrite($file_handle, $data)) { echo "Cannot write to file"; }
echo "Successfully written data to $filename!<br>";
...................

View Replies !
Create PHP Pages From List Of Files In Directory
this is probably easy for a php pro... but I cant figure it
out..

I have a directory of mp3 files named like this.
Chevy_Car_Commercial.mp3

There are about 150 files.

I am trying to find a script that will make php pages based on the file
names.
chevy_car_commercial.php

And also dump that variable title
Chevy Car Commercial into the <title> of the web page...

I have made dynamic pages before... but that was using a form..

View Replies !
Make Directory And Create Files In A Different Domain
Have a client with domains and subdomains

www.mydomain1.com
sub.mydomain1.com

They have a script that process a form under www.mydomain1.com, but need it to create a directory and file under the sub.mydomain1.com. These domains are under the same account, and the domain folders exist just like the domain name is setup.

I am trying the following from the www.domain.com form:

if (!file_exists('/sub.mydomain.com/newfolder'])) {
mkdir('/sub.mydomain.com/newfolder');
}

but I get the error: "mkdir(/sub.mydomain.com/newfolder): No such file or directory in"

So, is this error due to permissions or do I have to use something else to get to a different folder outside the form domain? Can this be done?

View Replies !
Create Directory When Files Are Uploaded To The Server
there i was just wondering if anyone could direct me on how to create a directory on the server each time files are uploaded to the server. i know its something to do with mkdir but im just new on all this.

View Replies !
Setup My Htaccess File To Read My Html Files As Php.
I am trying to setup my htaccess file to read my html files as php. How would I do this, or where can I find how to do it?

View Replies !
Can I Put Some Php Files In /var/www/ In A Directory Other Than Html?
I setup a local sever, the sever pages are in the /var/www/html/ and when i start the server, it opens the /var/www/html/index.html that is ok, now my question, there is some php files can i put them in a deferent directory then html in the /var/www/ for example /var/www/any_name, and then how i can open them with my server?

View Replies !
List All The HTML Or PHP3 Or TXT Files In A Variable-defined Directory
What I need to be able to do is to list all the HTML or PHP3 or TXT files in a variable-defined directory, with a little icon next to each one and each one needs to be able to carry a link. Anyone got any ideas as to how to do that? The link that needs to be carried will contain the name of the file.

View Replies !
Open A Directory And Set The Names Of The Files In That Directory In An Array
I'm trying to open a directory and set the names of the files in that directory in an array (ei. file[0], file[1],file[2]...) for howmany files there mey be in the dir.

View Replies !
How To Read A Text File Into An Array And Echo The Each Line?
how to read a text file into an array and echo the each line(each array element) by using file().

View Replies !
String Variable Read From Mysql DB + Echo = Newline Problem
Hi. I have this simple code:

===========================================
->Database query here
(.. some code)
$row=mysql_fetch_array($res);
(...)
$formatting2 = $row['formatting2"];
(..)
//Echo variable from DB
echo "$formatting2";
$formatting2 = "USERNAME: %1$s SERIAL: %2$s";
//Echo same string - this time from an "inline" variable
echo "$formatting2";
===========================================

Ok, maybe that was overly complicated. I hope you follow anyway. Whats
happening here is that I am getting a formatted string from a database
which I throw in a variable. What you see here is my test case to
visualize the problem. Now, when I echo this variable or pass it to
printf/sprintf then I get a different result than if I "manually"
create the variable inline in my php script.

So, the first echo $formatting2 there will output:

USERNAME: %1$s
SERIAL: %2$s

whilst the second shows the newlines correctly. Also printf/sprintf
barfs if I pass the string I got from the DB.

What the heck is going on here? Database returning some strange string
format?

View Replies !
Echo Current Directory
how to echo the current directory of something without getting the whole url (/home/user/public_html/folder/). So basically if it is in my forum directory I just want to get "/forum/" without the full document root. Anyone know how? I tried REQUEST_URI but the problem is it echoes the whole url (include the filename).

View Replies !
How To Copy Files From Ftp Directory To Web-accessible Directory?
I need to copy files from an ftp directory to a web-accessible directory and then delete the files in the ftp directory. (I am doing it this way because web-based form upload can not exceed 2MB and I can't change that)

View Replies !
How To Get Php.ini To Be Read In Every Directory?
Recently I changed of hosting company. I used to use .htaccess to change my PHP settings, but my new hosting company forbids that. Instead, they told me to use php.ini files. So I had to put a php.ini file in every directory of my website where I wanted special settings. Example:

  ~/public_html/admin/admin.php
  ~/public_html/admin/index.php
  ~/public_html/admin/php.ini
  ~/public_html/index.php
  ~/public_html/php.ini

php.ini is being read in every directory and the settings it contains are applied to that directory only (not recursive like .htaccess). Anyway, it works well.

My problem is: I try to reproduce that behavior at home, on my Windows 2003 server (Apache 2.0.55, PHP 5.2.2), and I really didn't found any clue anywhere about how to setup that! Is it in Apache, is it in php.ini, I just don't know.

View Replies !
Echo The Workind Directory And Change It?
is there any way that I can echo the workind dir? so later I can changed using chdir()?

View Replies !
Echo The Last Time Directory Was Modified..
I want to do the following in a PHP script: Get the time at which a directory was last modified, and then, if it was within the last 30 days, echo that time.

View Replies !
Problems With Read A Directory
I got a problem trying to read the files of a directory. I'm using sessions to use the variable that holds the directory. Is there a better way of writing the code to read and deisplay as an link? PHP Code:

View Replies !
Directory Read Problem
I am having trouble reading a directory. I can read a directory and loop through it no problem BUT only when the directory being read IS NOT the directory that the file with the code in it is in.

Does anybody know why? or possibly have some slick code that will allow me to get the path and strip out the php filename so that all I have left is the path MINUS the filename? or something similar?

View Replies !
Read A Directory And Subdirectories
How do you read a directory and subdirectories and use their filename as the output? like a search enginge script which searches a directory to find the user's input. how would i do that? i want to kno how to read the directory and make the filename into a string.

View Replies !
Read Directory Readdir
I want to read all the files in a folder & display them in a drop down menu. I'm using the code below & it works fine. I now want the file names to be sorted ascending before it is displayed in the drop down menu. How do I do that? Code:

View Replies !
Echo Directory Modification Date If Less Than 30 Days Old..
I am using the following code to echo the last modification date of a directory.  However, I want it to be conditional such that the modification date will only be echoed if it is less than 30 days old (based on the current date). Code:

View Replies !
Need PHP To Read File Date In Directory
Is there a way to use PHP to read the date of a file that is uploaded
into a directory and then print out that date on another page?

I'm looking to have a specific file (/texts/filename.pdf) located in the
directory and the date of its last change/modification printed into a
date("F, n, Y"); format on another page. I checked the PHP manual but
couldn't find any date/time functions that were what I needed.

View Replies !
Read A Directory With 17'000 Pictures
I have the following problem with the simplified script bellow!
When I start this script the first time files (~17000) are read in the /camera25 directory in less then 5 sec. When I click again on the same camera button ( second from the left), or reload button on the browser, I get a timeout from provider....

View Replies !
Strpos() Read Through A Directory And Look For A File
I am trying to read through a directory and look for a file, and once that file is found to set a variable with the name of the file. I have the code to open the directory like this and it is working fine ....

View Replies !
Changing Directory Read Order
I have made a small file management utility, but I still have a small design problem. When I read through the directory I get the folders and files in a mixed order since it is read by the time and date they were added, when I would like to get the folders first, and then the files.

Does anyone know if this can be done. I think I can probably get it done, by having one routine just reading all the folders in the directory, and then one routine reading all the files, but I was wondering if there was an easier way, or a smarter way :)

View Replies !
Read Image File From A Directory
Is there a way to read the width and the height of an image file stored in a specific location of a folder. I know how to use opendir() and readdir() to read it but i dont know how to get the image file width and height value. Is there a way in doing this?

View Replies !
PHP To Create CSV That Excel Can Read
I am using PHP 4.3.2 to create a CSV file, however, Excel constantly
views it as a single-column spreadsheet with everything in quotes,
whereas OpenOffice Calc views it as a legitimate spreadsheet in
separate columns/cells.

Code: ( php )

View Replies !
Create A Php That Would Read From A Flatfile
How do you show like items 1-20 and have it should items 21-40 and etc. How do you create pages for 1 php to display the items? I use to create each page 1 by 1 and I find that a hassle to do and thought.

I would create a php that would read from a flatfile and generate the links and text but I dont want it to show all of them I want them to have pages like if it exceeds 20 i want it to start a page 2 within the php.

View Replies !
Read Specific Entry From File Directory
Is there a way to use PHP to read forward from a specific starting point in a directory? Let's say I've opened a directory on a file system, I've read through the first X-number of entries, now I need to go do something else, but I want to come back later in the program and continue reading from the point I left off in the directory. This would be like reading through an array with an index value. Can I do this with a PHP construct of some kind, or do I have to call a shell script.

View Replies !
Create A Link In A Table From Echo 'ed Sql Data
im using the following code to output everything in a database table under headings in an html table untill theres no more data left. The headings are things like name address etc.

could i make it so when all the data is shown each name or ID becomes a link and when clicked takes the user to a more detailed page on the selected client.

because of the way the table is generated there is no where to place link tags. is there a more appropriate way that is more editable?

it would be nice to have checkboxes at the edge of each customer also to enable a complete status or deleting a client from the table. Code:

View Replies !
How To Create A Script That Will Echo A Message To The Browser?
I'm just learning how to create a script that will echo a message to the browser and also send the contents of a form to an email address once the submit button is pressed.

I'm trying to test it out with some code I got from a book, and I've attached the file with the php code in it in case someone would like to have a look (the instructions on this site didn't say you could attach a php file so I've made it a txt file just for troubleshooting). Code:

View Replies !
(without A Database) To Read Or Point To The Next/previous File In A Directory
just simple includes with some "thispage" and "you are here" variables to keep a navigation menu consistent across pages. It's a simple static site with no databases involved.

One thing I'd really like to be able to automate is the Next-page/Previous-page links on every page. The HTML files themselves have unpredictable names (2005-03-green-widgets, 2005-07-blue-widgets, etc.). Is there some way of using PHP (without a database) to read or point to the next/previous file in a directory, regardless of the file's name?

View Replies !
How To Read An Uploaded Filename To Create A Link ?
I want to read an uploaded filename, say "mypic.jpg" to create a link to this image without having to ask the users to enter the filename "mypic.jpg" when uploading it. My upload code works file but it's not on the same page. 

I'm working on my "index.php" page and included the upload.php page "<?php include("upload.php"); ?>" in it. Here's the sample of my code in the upload.php page Code:

View Replies !
Read Off An Uploaded File Name To Create A Link?
I want to read an uploaded filename, say "mypic.jpg" to create a link to this image without having to ask the users to enter the filename "mypic.jpg" when uploading it.  My upload code works file but it's not on the same page. 

I'm working on my "index.php" page and included the upload.php page "<?php include("upload.php"); ?>" in it.  Here's the sample of my code in the upload.php page (the code for the form is separate and not included here): Code:

View Replies !
How To Use Echo-php In The Html
please some one help. I want to pass the variables neatly in the below coloured boxes... how do I execute such using echo function.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="776" border="1">
<tr>
<td width="197">Name</td>
<td width="563" bgcolor="#00FFFF">&nbsp;</td>
</tr>
<tr>
<td>Address</td>
<td bgcolor="#006699">&nbsp;</td>
</tr>
<tr>
<td>Comments</td>
<td bgcolor="#00CCFF">&nbsp;</td>
</tr>
<tr>
<td>Delivery</td>
<td bgcolor="#006699">&nbsp;</td>
</tr>
<tr>
<td>Meals</td>
<td bgcolor="#00FFCC">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="#006699">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="#00CCFF">&nbsp;</td>
</tr>
</table>
</body>
</html>

View Replies !
Echo HTML And PHP
I have a script both HTML and PHP strings going in and out of PHP <?php ect, I want to echo it into my page but not sure how this can be done? maybe something using the urldecode function.

Could this work? if so how would i write the echo line???

View Replies !
Echo HTML
A simple script:

<?php
Echo "<html>";
Echo "<title>HTML with PHP</title>";
Echo "<b>My Example</b>";

//your php code here

Print "<i>Print works too!</i>";
?>


View Replies !
PHP Create Directory.
im strugling with this for days now... so please help ih you know...

it's UNIX server,

i'm trying to find working script that would create directories
recursively...

script is in www.server.com/cp/uploadfiles/script.php
and function should be called like 'createDir ("../../files/aa/bb")'

-> only "../../files" exists.

View Replies !
Create XML From Directory
I've been searching and searching I did find one class that does this but it only saves it to a file, and it was a bit beyond my talent to rewrite it to send directly to the browser. What I am trying to do is get an XML document that holds a direcetory structure from a given path. Surely someone has solved this before and can save me from reinventing the wheel. Idealy I'm trying to end up with something like

<galleries>
<fun>
<image>image1.jpg</image>
<image>image2.jpg</image>
</fun>
</kids>
<image>kidatplay.jpg</image>
</kids>
<galleries>

where the directory structure is .


View Replies !
How To Create Directory
i want to create directory in the same directory and update the database at the same time. currently i using iis, but it can't create directory. anyone can suggest any sample code to create directory?

View Replies !
Create New Directory
I want to create a new directory. The new directory should be placed relative to the script that is creating the directory. This should work on diffrent locations on the server. So I need a way to find out the path to the script.

Is there such enviroment variable in php?

Should I use mkdir()?

View Replies !
Echo, Print Or Mix With HTML
Hi there,

I've just started into serios PHP-development, so far I sometimes mixed echo- and print-statements and switching in and out of php-mode (<?php ... ?>) to display static HTML-Content.

But I think I should concentrate on one method to make my sources more readable.

So here are my questions:
1) what's the difference between echo and print?
2) What are the advantages and disadvantages of "echoing"/"printing" static HTML-Content and switching in and out of php-mode?

Well one advantage I see to switching in and out is the readablity of the HTML code in an editor with syntax-highlighting, but the readability of the program-structure suffers. Are there any technical (i.e. Speed) considerations?

View Replies !
Is It Better To Echo Or Leave As Html?
I have a multi step signup form that I'm building and I have the
following question. Should I do it this way:

<?php

if (blah == 1) {
?><table><td width="100">........etc
<?php } else { ?>
<table><td width="100">........etc
<?php } ?>

OR

<?php

if (blah == 1) {
echo "<table><td width="100">........etc";
} else
echo "<table><td width="100">........etc";
}?>

If the second way is better is there an easier way to convert the HTML
rather then writting echo a million times by hand?

View Replies !
Escaping HTML While Using Echo
I'm writing my first PHP program which is supposed to fetch an external HTML source and display it. I have the HTML source stored as the variable $pageContents, but when I try to echo it out the browser renders the HTML. This is understandable, but can I somehow just output the raw HTML code without the browser trying to render it?

View Replies !
Setting Up HTML In PHP Echo
I am working on making a drop down box with in my PHP echo. Can some let me know if this is right?

echo ("<td><select name='WebCaseTypeSet'>".$no_opt. "</option>" .$yes_opt. "</option></select><big></big></td>");

View Replies !
Mixing Html And Php Without Using Echo
i am familiar with the basics of echoing, but i suppose there is a way to not use echo, so as to avoid escaping characters and such .

View Replies !
How Do I Use Echo To Print Out HTML.
How do I use echo to print out HTML. I want to be able to use it an a conitional statement and just regular. For example

if (mysql_affected_rows() == 1) { //( HOW DO I ECHO HTML HERE))?

View Replies !
Echo Html Tags Or Not
Is the any advantage to this:

<?

echo "<input type="submit" value="Empty Cart" name="empty_cart">";
echo "<input type="submit" value="Update Cart" name="update_cart">";

?>

over this...

<input type="submit" value="Empty Cart" name="empty_cart">
<input type="submit" value="Update Cart" name="update_cart">

...or vice versa?

View Replies !
Echo A " For Html?
I am having trouble finding a sollution on displaying quotes like for the html code:

<img src="http://domain.com/picture.jpg">

how can this be done?

View Replies !

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