Ok heres wot i’m trying to do starting from the top – I have an article upload feature on my site which i wish to add images to. Basically when you add an article using the form you have a button that you click if you have images relating to the article to upload. This button then opens a small ‘pop-up’ window which has an image add form. With this form you browse the loacl system for the image you want to add, give a description, then upload. You then go back to the main form to finsh it off. As not all articles will have their own pictures i came up with the following idea (all articles are store in a datbase by the way):
First you have the articles table in the database which has article_id (set to auto_increment), article_title, article_content, and then a images field which can be set to either 0 (no images for article) or 1 (has images). This is so that when an article is being loaded the script will check the images field to see if the article has images or not, and if it does opens the article in a template which has a image thumbnail on the right which can be clicked to open a gallery of all images related to the article.
Second their is the images table. This has image_id (set to auto_increment), image_path (the actual path to the image to be used to display it), image_desription, and article_id (which article it relates to). So when the image template is opened it querys the database for images with article_id’s that match the article that is being loaded and places a cutdown version (probably just set image height, width to thumbnail size) of the first image in the set place. Then obviously the image can be clicked for full size and this allows browsing of the other related images.
Right heres my question….how do i do all this?
Only kidding….my real question is that i’m using a button with “onClick open the add image pop up window” – how do i pass the article_id to the new pop up window to be added to the images table? Just to clarify my question, When you’re creating the article you don’t know the article_id as it is set by the database (athough it is always going to be article_id of the last entered +1) so how do you get this number and send it to the new window (when the add image button is pressed) with out submiting the form that the buttom is in? I’ve got the image adding sorted all i need to do is complete the updating of the database but this little problem is standing in my way :mad:.
Also what do you think of my system in general? Is their a better way?
I’ve got confussed just writing all this (and i know what i’m on about) so god knows how much sense it’ll make to you guys that don’t know whats going on in my head? ?
Cheers,
Durbs