Solved

How to set different filename in one row in database

Posted on 2008-06-10
1
182 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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

743 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

15 Experts available now in Live!

Get 1:1 Help Now