l17wnj Posted December 3, 2008 Share Posted December 3, 2008 I am using mysql4.0 I am trying to create a gallery section for a website where users can create a new database and upload pictures. I have created the tables and the php script to create the new row and to edit existing rows. However i want the users to be able to insert up to fifty images in each row and uploading this on a single page would be impractical (timeout etc.). Is it possible to upload the images in smaller groups and assign them to the first available field. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/ Share on other sites More sharing options...
corbin Posted December 3, 2008 Share Posted December 3, 2008 Why would you store 50 images in one row? That doesn't make much sense. What is your table schema? Quote Link to comment https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/#findComment-705514 Share on other sites More sharing options...
l17wnj Posted December 3, 2008 Author Share Posted December 3, 2008 This is for my local football club and they want anyone to be able to add their own images to the site so there may be thousands of images in the gallery eventually. I am trying create something similar to the galleries in social networking sites and i thought it would be easier to do it this way than creating a new table each time. id (primary key)(auto increment) date name image1 ... image50 description1 ... description50 Quote Link to comment https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/#findComment-705527 Share on other sites More sharing options...
corbin Posted December 3, 2008 Share Posted December 3, 2008 Oh... Errr... Database normalization is your friend. Google it. A better way to do it would be like: CREATE TABLE users ( user_id int AUTO_INCREMENT PRIMARY KEY, --other fields ); CREATE TABLE user_images ( image_id int AUTO_INCREMENT PRIMARY_KEY, user_id int NOT NULL, image_path varchar(255) NOT NULL, description text ); Then, users could have any number of images in user_images mapped back to their user by user_id. (A 1 to many relationship.) Quote Link to comment https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/#findComment-705533 Share on other sites More sharing options...
l17wnj Posted December 3, 2008 Author Share Posted December 3, 2008 there won't be any user profiles on this site it is open to everyone so they can upload their own pictures of club events for all to see. Quote Link to comment https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/#findComment-705535 Share on other sites More sharing options...
l17wnj Posted December 6, 2008 Author Share Posted December 6, 2008 I have taken the recomendation to create a new table for each new gallery but i can't get a form to create a new table if($_GET['mode'] == "add") { //////////////////////////////////add gallery to DB////////////////////////////////////////// $sqldate = date("Ymd"); $name = $_POST['name']; $sql3 = mysql_query(" CREATE TABLE $name ( `pk` int(11) NOT NULL auto_increment, dateentered varchar(255) NOT NULL default '00000000', description text NOT NULL, image varchar(255) NOT NULL default 'noimage.gif', PRIMARY KEY (`pk`) ) ") or die ( mysql_error() ); $sql2 = "INSERT INTO gallery VALUES ( '', '$sqldate', '$name'"; if ( @mysql_query($sql2) ) { $msg = "Your have succesfully Created your new Gallery"; }else { $msg = mysql_error(); } }?> Quote Link to comment https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/#findComment-707803 Share on other sites More sharing options...
fenway Posted December 8, 2008 Share Posted December 8, 2008 Why is your form making the table? Quote Link to comment https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/#findComment-708928 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.