Jump to content

[SOLVED] Add image to row


l17wnj

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

}

 

}?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.