Inserting MySQL records questions
Posted: Thu Mar 30, 2006 11:45 am
Ok, I'm bad at explaining, so I hope I don't confuse anyone.
I have 3 pages.
One is the gallery of photos
Second page acts as if it's not there, but it's the middle guy. It's a php page that inserts the selected photos into the database.
Third page is like the "Cart" page that shows the selected images for the specified gallery/album.
Now, when a user chooses some photos in the first page via check boxes, they get sent to the 2nd page and the 2nd page right away sends them to the cart page. Here's an example of the cart page:

There's a drop down on the top left side. That button allows you to add more other available sizes. That's where I'm stuck. I don't know how to set it up. Here's a view of the items table in MySQL:

As you can see, the selected files are there. Now, as the user selects an additional size, the php page cart.php will run a MySQL Insert Query. As you see in the image of the database structure, id is blank. That's because that's the original one. When a size is added, I want to insert a new row. This row will have the id col. corresponding with the proper itemid but only within the same albumid. Also, col. itemname will be empty, since I want it to be reffering to the id.
Here's the piece of code used to insert the row ONLY when selected in the drop down.
Here's the TXT file of the php script. I think it would make the post very long, so I posted it as a txt file. If you need more explaining, I'll do my best to make it alittle more clearer. My apologies if I'm not too clear. Thank you for your time in assisting me.
I have 3 pages.
One is the gallery of photos
Second page acts as if it's not there, but it's the middle guy. It's a php page that inserts the selected photos into the database.
Third page is like the "Cart" page that shows the selected images for the specified gallery/album.
Now, when a user chooses some photos in the first page via check boxes, they get sent to the 2nd page and the 2nd page right away sends them to the cart page. Here's an example of the cart page:

There's a drop down on the top left side. That button allows you to add more other available sizes. That's where I'm stuck. I don't know how to set it up. Here's a view of the items table in MySQL:

As you can see, the selected files are there. Now, as the user selects an additional size, the php page cart.php will run a MySQL Insert Query. As you see in the image of the database structure, id is blank. That's because that's the original one. When a size is added, I want to insert a new row. This row will have the id col. corresponding with the proper itemid but only within the same albumid. Also, col. itemname will be empty, since I want it to be reffering to the id.
Here's the piece of code used to insert the row ONLY when selected in the drop down.
Code: Select all
//The following block adds an additional size
if($_POST['addsize'])
{
$addedsize = $_POST['addsize'];
mysql_query("INSERT INTO items (id,albumid,cartid,size,paper,quantity,userid,isphoto) VALUES ('$itemid','$albumid','$cartid','$addedsize','$paper','$userid','yes')");
}