CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 How to index the files in a folder and create MySQL records

Print topic Send  topic

Author Message
Markie


Posts: 251
Posted: 07/29/2008, 10:16 AM

I'm working on a photo project. Of course, I will make it with CCS. I want to host a large amount of professional photos. However, I don't want to add a record in the MySQL table for each photo. I would like to know if it's possible to index the contents of a folder and automatically make a MySQL record for each photo in the folder.

If this is possible, where do I start.

Thanks in advance,

Markie
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL
View profile  Send private message
jjrjr1


Posts: 942
Posted: 07/29/2008, 11:01 AM

Hi

I think the easiest way to do it would be write a php script that would get all the filenames then insert into a databse

Get the file names in a directory like this.

<?php
$dir = ".";

$dh = opendir($dir);

while (($file = readdir($dh)) !== false) {
echo "<A HREF=\"$file\">$file</A><BR>\n";
}

closedir($dh);
?><?php
$dir = "."; // what ever foler you want to index

$dh = opendir($dir);

while (($file = readdir($dh)) !== false) {
DO SQL INSERT HERE WITH $file; Do what ever data insert you need here
}

closedir($dh);
?>
If you wanted to you could even create the php script in CCS so you can use CCS sql libraries.

Does That Help?

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 07/29/2008, 11:03 AM

BTW
The first code block would take each file and make a URL out of it. The scond block shows sql more or less.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 07/29/2008, 11:17 AM

Hi Again

I think this is kind of a cool issue. Consider after you get the filename, get the exif information for the photo and put it into the database at the same time. Since the site seems to be for professional photos, that info is probably in the image and would be sort of fun if you were able to display that along with the photo.

Here is a link where a php exif reader writer can be found.

http://www.phpclasses.org/browse/package/1042.html

Let me know if you implement it with this.

Have fun.

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
Markie


Posts: 251
Posted: 07/29/2008, 12:36 PM

Hi jjrjr1,

Thanks for your input! I will certainly use your ideas

Markie
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.