close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Pointer in the right direction required

Thread began 9/11/2009 6:30 am by John Langer | Last modified 9/14/2009 12:02 pm by John Langer | 3150 views | 6 replies |

John LangerBeta Tester

Pointer in the right direction required

Hi,

I'm assuming that Dynamic Dropdowns will be involved here, hence posting in this forum.

This is what I want to do. I'd be grateful of some pointers in the right direction.

The overall view is that members of a site can create a mailing list. (This I've done). I then want the member who has created the list to then be able to choose other members of the site to add to the list to be a recipient of the emails.

So The member creates the list (this is done) and then moves to the next page taking the listID with them.

Here, I'd like them to see a list of other members and to be able to pick them and add them to the listMembers table.

The table for the mailing list is:

mailingListID (Auto increment)
name (The name of the list)

The people table has

peopleID (auto increment)
firstname
lastname
email

the listMembers table has

listMembersID (auto increment)
MailingListID (this is the ID of the mailing list (Foreign Key))
peopleID (this is the ID of the member (Foreign Key))

So you arrive on the page with the mailingListID parameter, see list of other members from the People Table, pick the ones you want and have them added to the table listMembers. So it will add from one to 100 (or more) records to the listMembers table.

The layout of the tables is inherited from the previous site and already has data so it would be difficult to alter these tables.

The result in MySql would look like this

listMember table

listMemberID MailingListID peopleID

1 88 23
2 88 56
3 88 78
and so on

I'm assuming that Dynamic Dropdowns would do this but as yet have been unable to actually get it to work :(

Then the plan is to use dataAssist to insert the records. But I also want to be able to edit the "listMembers" it just seems to get more and more complicated...

Could someone just give me some structure to work to.

Sign in to reply to this post

Jason ByrnesWebAssist

Create a recordset to pull all of the records from the people table.

We will need to have at least the peopleID and email address.


Add two multi select lists to your page, the first one will be set to be dynamic and use the people recordset. Set the label to the email address and the value to the peopleID column.

name the second select list "people[]"

You will then add a button to the form, not be submit buttons, just standard button:
<input name="button" type="button" id="button">


Select it in design view, and on the Behaviors panel, use the Dynamic Dropdowns Add Value From Source List to Target List behavior.

Also add a submit button to the page.



This will have a select list that gives you the ability to chose the people you want and add them tho the people select list. Since the name of the people select list is "people[]" it will create an array of all of the selections.

assuming you are storing the mailingListID value in a hidden form element named mailingListID, you would need to hand code the insert record behavior to loop through the array, something like:

php:
<?php

if(isset($_POST["people"]) && is_array($_POST["people"])) {
  
$count count($_POST["people"]);
  for(
$i 0$i $count$i++) {
    
$sql "INSERT INTO listMember (MailingListID, peopleID) VALUES(".$_POST["mailingListID"].", ".$_POST["people"][$i].")";
    
mysql_select_db($database_localhost$localhost);
      
$Result1 mysql_query($sql$localhost) or die(mysql_error());
  }
}
?>
Sign in to reply to this post

John LangerBeta Tester

Thanks Jason, I'll give that a try and let you know how I get on.

Sign in to reply to this post

John LangerBeta Tester

Well, it all works fine until I get to the bit about inserting into database. That doesn't work.

I've spent about 8 hours now trying all sorts of things but nothing seems to work. I can display the emails and choose them. Add them to the target list, click submit and the page refreshes but nothing gets placed in the database.

I know it's the weekend so Jason won't be seeing this until Monday so can anyone else help please? My deadline is Monday so I'm in a bit of a state!!

Sign in to reply to this post

John LangerBeta Tester

:o

It's OK, forget my request it all works. I had no idea that you had to select the items again in the target list. It was only reading another forum post (he made the same omission) that I realised that that had to be done.

8 hours for a stupid lapse!! Oh well, you live and learn.

Sign in to reply to this post

John LangerBeta Tester

Continuing on from this I now have a problem with the SQL

PHP MySql

I have three recordsets on the page (all created through DW server behaviours)

The aim is to have a list of people to choose from (see above) but exclude those that appear in another list.

So the first recordset gains it's ID from a previous page and the ID is given through a URL parameter "../add_to_list/add_member_to_list.php?listID= ) This gives the result of "95" in my testing instance.

Recordset name = rsList
SELECT id, name
FROM bbc_lists
WHERE id = colname

colname=
integer -1
runtime value = $_GET['listID']

This is tested and works.

The second recordset takes that ID and lists all the people who are already in it

Recordset name = rsListMembers
SELECT person_id, list_id, id
FROM bbc_listmembers
WHERE list_id = colname

colname =
integer -1
runtime value= $row_rsList['id']

tested and works.

The third recordset is the one that is proving troublesome. It is supposed to list the people (which it does) but not those that appear in the second recordset

Recordset name = rsPeople
SELECT id, firstname, lastname, realmail
FROM bbc_people
WHERE id <> colname
ORDER BY lastname ASC

colname =
integer -1
runtime value = $row_rsListMembers['person_id']

The rsListMembers recordset returns two "people" (in my testing scenario)

The result of running the third recorset is that the first person to appear in the list is omitted (correctly) but the second person remains. So it would appear that it doesn't "run through" the table to get to the second name. It stops after reaching the first one.

I'm sure it's something simple but it baffles me.

Any help, as always, most appreciated.

Sign in to reply to this post

John LangerBeta Tester

Solved

Steven Seiller over at CMX solved this for me. Seems you need a sub-select

SELECT bbc_people.id, bbc_people.firstname, bbc_people.lastname, bbc_people.realmail
FROM bbc_people
WHERE bbc_people.id NOT IN (SELECT bbc_listmembers.person_id FROM bbc_listmembers WHERE bbc_listmembers.list_id = MMColParam)
ORDER BY lastname ASC

MMColParam = $row_bbc_listmembers['list_id']

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...