Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/135432-solved-add-image-to-row/
Share on other sites

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

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.)

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();

}

 

}?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.