PDA

View Full Version : Select Multiple/Echo where assigned question


Ted Varnson
11-15-2005, 07:50 PM
First of here is my goal. I am creating a control panel to be used by the admin of at least 4 different sites. Each site is in the data base in the sites table.

What we have at the moment are 4 affiliated band sites that are going to be posting blogs while they are touring around the country together. All of the blogs will go into the same database table. However what I want to do is be able to assign each post to a site.

I have it set at the moment to be assigned to 1 site (and it will display on that sites blog page), however we are needing to have the option to assign the blog to display on say site 1 and 2, site 2 and 3, site 1 and 4, so on and so forth.

I have set up a select multiple box that displays all the sites that can be chosen, where I run into trouble is how to store the assignment in the database.

As is I can see that if I put it in an array and send to the DB it is store as the numbers of the site IDs combined.

Sorry for the lengthy post, just wanted to cover my bases. Any suggestions will be helpful. I'm not totally versed in PHP, but have a medium understanding of it.

Thanks a lot.

TheShaner
11-15-2005, 08:24 PM
tblBand
----------
*bandID
bandsite

tblBandBlogs
---------
*blogID
*bandID

tblBlog
-------
*blogID
post

* denotes key

SELECT tblBand.bandsite, tblBlog.post
FROM tblBand INNER JOIN (tblBandBlog INNER JOIN tblBlog ON tblBandBlog.blogID = tblBlog.blogID) ON tblBand.bandID = tblBandBlog.bandID

You will then receive records where a band site is linked to a blog post. A band site can have multiple posts and a single post can be linked to multiple band sites. Use a WHERE clause to choose a band site or to choose a specific post.

-Shane

Ted Varnson
11-15-2005, 11:14 PM
The problem I'm running into with that is the blogid is going to be autonumbered into the blog table, so it would have to be linked to the site in a second step.

Anyway you can think of to do this all in one step?

This is the layout I have right now, I'm a visual type of person so maybe this will give you a better idea what I'm talking about.

Thanks for getting me started.

Ted Varnson
11-16-2005, 10:03 PM
Nevermind got it, thanks for pointing me in the right direction :)

TheShaner
11-16-2005, 10:27 PM
Glad you got it! :thumbsup:

-Shane