473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Difficulty updating multiple images,need a hand !

58
Hey you all !
Happy holidays !


I have 2 tables:
Ads
ad_id primary
...
..

Adimages
image_id primary
ad_id FK
......
.....

I make sure to link each ad to its multiple corresponding images,using this:
$ad_id1 = "";
if($ad_id1 != $ad_id){
$ad_id1 = $ad_id;
}

so ad_id=58 in Ad table,will have 3 corresponding images(3 Foreign keys ad_id=58) in Adimages

am tyring to edit a user ad that is linked to 3 images:
image1
image2
image3
If a user wants to replace the images with new ones,say replace all three with just one-image4

i run this query:

[php]
$query="UPDATE Adimages SET name='$newfile',type='$type',size='$size',path='$p ath' WHERE ad_id='$ad_id' ";
mysql_query($query,$conn);
[/php]

The result I get is:
image4
image4
image4

normal,since all the images have the same foreign key(ad_id) related to one primary key(ad_id) on which the WEHRE clause was based.

How can I update all those images with one image?
so the result will be:
image4

Basically,I need a function that deletes all old rows,then allow new inserts.If i delete,the ad_id reference to 3 images is lost and only inserts1 image instead of 3

I tried REPLACE,but it only inserted a fourth new row(may be i need an advanced REPLACE or some special INSERT approach !!!?)

Any help would be very much appreciated !
my gratitude in advance.
Dec 28 '07 #1
0 1128

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: scott | last post by:
Hi, I'm having some trouble with something that should be relatively easy. I want to update multiple rows in one of my database tables simultaneously. In my table I have these values: ...
10
by: IWP506 | last post by:
Hello everyone. I have a header picture for my website with text on it like "Home" "links" "about" etc. It's all 1 picture. I've seen people's sites where they have 1 picture but somehow make...
0
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main...
3
by: Arun | last post by:
Hi, I have simple question to ask. How to write multiple Binary files to the Browser using Asp.Net and Visual C#.net I have seen examples where single binary file is written to browser. ...
1
by: FuzzyLogik | last post by:
I need the image to be in the CSS, because I plan to have multple stylesheets. The tricky part is I have 3 parts to the image, a top, the main bit, and right, Here is the image:...
1
by: zags | last post by:
I've tried a couple suggestions on this, but so far I still can't figure out an efficient way to do this. Hopefully someone can help me out. I have an access db that uses tables from an ERP db in...
2
by: julie18881 | last post by:
I may be being really stupid here, i have spent the last 3 hours looking round your site and some other for answers to my problem, but have not had much luck (possibly cuase my brain just isn't...
11
by: Jankie | last post by:
I need to dispaly a user's multiple images in one entry.Right now,say if a user uploads 3 images,three entries for the same id display to match 3 images. I only want 1 entry to display all of a...
5
by: rosaryshop | last post by:
I'm working a jewelry/rosary design web site at http://www.rosaryshop.com/rosariesAndKits2.php. As the user makes selections, it updates images of various parts, giving them a preview of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.