Jump to content

PattyB

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

PattyB's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am trying to compare the values of two things. The first set of values comes from a multi-select and outputs like this:  item1,item2,item3,  and etc. for however many options I choose.  I am not sure if this needs to be converted into an array or if it can stay like is? The second set of values comes from a mysql table.  Say this table contains two fields: email and groups. What I want to do is compare the first output (item1,etc) to the value of what is in the field groups and have an if statement if there is a match. For example:  I have a list of users in a table along with their email and groups they belong to.  The user will select the groups they want from a multi-select.  I want to compare the groups selected to the groups each user belongs too and if there is a match to do something. Im guessing array_intersect can play a role in this but I have been playing for a while and cant get anything to work.  Any help would be very grateful.
  2. Hi all, I am trying to make a user-uploaded file attachment with Swift and read here http://forums.devnetwork.net/viewtopic.php?p=323522#323522 to do it this way: Upload the file, using $_FILES['form_field_name']['tmp_name'] as the path: php: $swift->addAttachment($_FILES['foo']['tmp_name'], $_FILES['foo']['name'], $_FILES['foo']['type']);  I get the file to attach and send however when I open the files all that is in it is: C:\WINDOWS\TEMP\php6E.tmp Anyone know what is causing this? Thanks.
  3. Hi, I have the following code using date_format but it does not return anything.  Am I using this right or is there a problem somewhere else?  If I have just date it returns the value fine. [code] $newsquery = "SELECT id, author, title, article, date FROM news order by date DESC LIMIT 0, 3"; $newsresult = mysql_query($newsquery); while($row=mysql_fetch_array($newsresult)) { ?> <tr width=100%> <td width="40%" align="left"> <?php echo $row["date_format(date, '%m-%d-%Y')"];  ?> [/code]
  4. Yup that was it.  Thanks so much!  :)
  5. This code takes an array from some user input and matches it to an array stored in a field in a database.  The first foreach should loop through each value from the user input.  The second foreach should take the value from the first foreach and match it to each value in the database.  I cannot get the outside foreach to loop through.  Ex:  User selects 1,2, and 3.  The code will only process 1 and not 2 or 3. Here is what the ouput looks like: No Match Groups from database:2 User-selected:1 Match Groups from database:1 User-selected:1 No Match Groups from database:3 User-selected:1 Here is what the code looks like: [code] <?php $sql = "SELECT * FROM members";  //Set parameter for query $results = mysql_query($sql);    //Get data from database $groups_input_parsed = unserialize($groups_input); //Parse Mail Form and store foreach($groups_input_parsed as $list_group)  //Roll through each selected checkbox { while ($row = mysql_fetch_array($results))    //Roll through each row in member database {         $id = $row["id"];                      //Store ID         $email = $row["email"];                //Store Email $groups=unserialize($row["groups"]);    //Parse Group array foreach($groups as $groups1)            //Roll through group database         {         if ($groups1 == $list_group)            // If member group is equal to selected group {             printf("<p><b>Match</b> <br>"); //Do Stuff Here printf("Groups from database:"); echo $groups1; printf("<p> User-selected:"); echo $list_group;         } //end if else //Otherwise there are no matches {             printf("<p><b>No Match</b> <br>");  //Do Stuff Here printf("Groups from database:"); echo $groups1;  printf("<p> User-selected:");      echo $list_group;         } //End else }  //End Inside foreach }                                              //End While } //end outside foreach ?> [/code] This probably isn't the best way to it but I am new to php.
  6. Hello, I am currently trying to build a small mailing list. In the mysql table storing the subscribers info (called members), I have a field called groups. This field is populated from checklists and using serialize to store the values. (I know I shouldnt do it this way, but it has worked for the rest of the mailing list). I have created the page to send mail and on that the users checks what groups they want to send to. These results are sent to the form with $_POST['groups_input']. What I need help with is taking the array from the _POST, breaking it down by individual group, and comparing each of those to the array stored in the groups database. If there is a match than it would send the email. Im guessing to start I need to do something like this to break down the _POST into individual groups and put all the code in between the brackets : $selected_list = unserialize($groups_selected); foreach($selected_list as $list_group) { } Im new with all this and help would be very appreciated!
×
×
  • 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.