Jump to content

select information, then build an insert query help?


tjburke79

Recommended Posts

I hope I have posted this in the right area but I am hoping someone can help me out. But its kinda mysql and php related...

 

What I am trying to do is, query a members database to see if they have uploaded any new photos to there account.  once i find out what photos are new, i would like to insert a single entry into a feeds table with field that has a comma separated value so that i can later use the explode function to see what new photos where uploaded in my members feed's application.

 

// select latest uploaded photos

 

SELECT MemberID, PhotoID

FROM Photos

WHERE DateTime >= '2011-05-04 13:02:18'

ORDER BY MemberID

 

this will output example...

1 | 11

1 | 15

1 | 89

2 | 68

 

so i guess where i am stuck is based on this select, how would i go about building a single entry per MemberID into my Feeds table?  I would have to do use the loop and an implode function I am guessing but not to sure how to put it all together.

 

// implode mysql result

$comma_separated = implode(",", $array);

 

what i need to do is compile the results so that i can make a single entry into my "Feeds" table per MemberID...

 

insert one entry into feeds per MemberID an example would have to be like this..

 

INSERT INTO `Feed` (`MemberID`, `Data`) VALUES ('1', '11,15,89,97')

INSERT INTO `Feed` (`MemberID`, `Data`) VALUES ('2', '68')

 

I hope I explained myself on what I am trying to accomplish here. Any ideas or a better solution to what i am trying to do? I would rather have one entry then a new entry for every new photo. Thanks for your time.

Link to comment
Share on other sites

The Data field on the "Feeds" table will store the temporary information, so in the feed i can select the MemberID and explode $Data to get the latest PhotoID's for that MemberID... My problem is building that initial query and loops compile the information to create the insert query  :shrug:

Link to comment
Share on other sites

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.