View Single Post
Old 06-29-2008, 05:10 AM   #7 (permalink)
pradeepsomani
The Visitor
 
Join Date: Jun 2008
Posts: 2
Thanks: 0
pradeepsomani is on a distinguished road
Default

Quote:
Originally Posted by sarmenhb View Post
hi, im creating a script that will allow multiple users upload multiple images and will view the images only that they uploaded.

this is the table structure i used

Code:
id
username
title
image
as you can see i added the username column which will be grabbed from the cookie. now my question is , is this the right way of doing this? if i had 100 people login to this script and each person uploaded 10 images to this table and their images were displayed neatly to them in a table. how else can this be done?
thanks

ps: this is what the table might have looked like after having 3 people upload 5 images each.

Code:
id: 1
username: bob
title: cartoon
image: someimage.png(encoded)

id: 2
username: bob
title: balloons
image: someimage.png(encoded)

id: 3
username: bob
title: ocean
image: someimage.png(encoded)

id: 4
username: bob
title: pc
image: someimage.png(encoded)

etc.....
then when i want to display each users images i would run a query like this

Code:
$username = $_COOKIE['username'];
$sql = mysql_query("select * from tbl_logos where username = '$username'");

while($row = mysql_fetch_assoc($sql)) {

echo data.....

}
Please Check the attached database design.

MySQL code

Create table tbluser (
userid Int NOT NULL AUTO_INCREMENT,
username Varchar(20),
userpassword Varchar(20),
userdeleteflag Bool,
Primary Key (userid)) ENGINE = InnoDB;

Create table tblimage (
imageid Int NOT NULL AUTO_INCREMENT,
userid Int NOT NULL,
imagefile Varchar(50),
imagetitle Varchar(50),
imagedeleteflag Bool,
Primary Key (imageid)) ENGINE = InnoDB;


Alter table tblimage add Foreign Key (userid) references tbluser (userid) on delete restrict on update restrict;
Attached Thumbnails
multi-users-uploading-image-table-db.jpg  
pradeepsomani is offline  
Reply With Quote