Solved

How to set different filename in one row in database

Posted on 2008-06-10
1
184 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to send multiple emails at the same time in PHP 12 57
Move wordpress site 3 38
php construct 5 26
How to properly use session_regenerate_id when user logs in 7 37
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
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.

776 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