Solved

How to set different filename in one row in database

Posted on 2008-06-10
1
183 Views
Last Modified: 2013-12-13
PHP

i have a table, i call it GETFILENAME
in GETFILENAME i have 2 field one call "description" and another one call "filename"
in filename i have 3 record called "test1","test2","test3"
this "test1","test2","test3" is a file-name.


if writing in PHP i can write
$file1 = test1;
$file2 = test2;
$file3 = test3;

and each file is differentiate by different variable name

but

in the database i only have one field called filename and this filename is the variable name for that 3 record
as this

$GetFileNameReturn[$j] = $row['filename'];
foreach($this->GetFileNameReturn as $FileName)
    {      
    $filename = test1;
    $filename = test2;
    $filename = test3;
    }

above code shows 3 different file are assigned to the same variable filename
suppose i only need 3 times to create 3 different file but now i need 9 time to create 3 different file
How to do this
pls help











0
Comment
Question by:firekiller15
1 Comment
 
LVL 5

Accepted Solution

by:
allmer earned 250 total points
ID: 21757357
Not knowing anything about what you are trying to do let me give just a very small advice.
Either loop through the files you get from the database directly
and perform whatever you need to do directly
or
Use an array which will contain your filenames (see snippet).
If you need to know additional information about your files to decide what
to do with them you may want to store that in the DB as well e.g.: FileType (txt,jpg,..)
Hope this helps
$index = 0;

$filename = array(); //Not really neccessary

foreach($this->GetFileNameReturn as $FileName)

{      

    $filename[$index++] = $FileName;

}

//Now all files are stored in the $filename array and you can 

//access them by their indices.

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now