473,545 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check Box and Arrays

2 New Member
I have columns named -email- rookie- -coach- -minor-


R1. email has an address rookie has a value of the word "yes"
R2. email has an address coach is empty
R3. email has an address minor has a value of the word "yes"

OBJECTIVE:

When I submit the form with all three boxes check it should only send an email to rookie and minor because their values are "yes"

PLEASE HELP ME!

I know the code below doesn't work, but it's what I've been staring at with no solutions.

I have the email code working fine. I put an echo down there because if it will echo then I know I can send an email.

THANK YOU!!!!
Expand|Select|Wrap|Line Numbers
  1. mysql_select_db("lhbrb", $con);
  2.  
  3. $names = array($_POST['rookie'],$_POST['minor'],$_POST['coach']); 
  4.  
  5.  
  6.  
  7.  
  8. $result = mysql_query("SELECT email FROM testemail WHERE $names='yes'");
  9.  
  10.  
  11. while($row = mysql_fetch_array($result))
  12.   {
  13.   echo $row['$names'] . " " . $row['email'];
  14.   echo "<br />";
  15.   }
  16.  
  17.  
  18.  
  19. mysql_close();
  20.  
  21.  
  22. ?>
  23.  
  24. <form action=...php method=post>
  25. <input type=checkbox name="cb['rookie']"></td>
  26. <input type=checkbox name="cb['minor']"></td>
  27. <input type=checkbox name="cb['coach']">
  28. </form>
Aug 8 '07 #1
7 1728
pbmods
5,821 Recognized Expert Expert
Heya, PR. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Aug 8 '07 #2
phpretard
2 New Member
Sorry about not posting the code correctly.
Aug 8 '07 #3
kovik
1,044 Recognized Expert Top Contributor
I remember this from yesterday... Same posting name and all. :-P

I'm not sure if you remember, but I'm pretty sure we told you to build the query using the submitted checkboxes. What you are doing is literally telling SQL "WHERE Array = 'yes'." Maybe the implode() function will shed some light on what you could do instead.
Aug 9 '07 #4
pbmods
5,821 Recognized Expert Expert
I remember this from yesterday... Same posting name and all. :-P]
PM me with the link to the duplicate, and I will investigate.
Aug 9 '07 #5
erp23
26 New Member
i've done something similar - the action page is quite simple.
I have set the value of the checkbox equal to the email address that I want it sent to, which is pulled from mySQL and placed in the field like this:

[PHP]echo "<input name=\"email[ ]\" type=\"checkbox \" value=\""; echo $row_rs_other['emailAddress']; echo"\" />";[/PHP]


Once you submit the checkbox values, this should work fine in the action page:
[PHP]$data = implode(", ", $_POST['email']);[/PHP]
Only the selected checkboxes have a value
Then use $data in the as the to variable in mail(....
Aug 9 '07 #6
kovik
1,044 Recognized Expert Top Contributor
PM me with the link to the duplicate, and I will investigate.
Oh! No no, not here on TSDN... Over at DevNetwork.
Aug 10 '07 #7
kovik
1,044 Recognized Expert Top Contributor
Only the selected checkboxes have a value
Then use $data in the as the to variable in mail(....
Those are the only checkboxes that are posted. If you want to have ALL of them and determine which are on or off, you need to create an array of all of the options, and then do a comparison of the posted data with the options you defined.
Aug 10 '07 #8

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

Similar topics

3
3699
by: Rex_chaos | last post by:
Hi there, I have a question about using expression template. We know that the final calculation in expression template will end up with a series of element-by-element operations. The concept can be explained with W = X o Y o Z; (here o denotes any operator) W.operator = LOR(LOR<X, o, Y>, o, Z); and in W.operator=, we have
15
2105
by: tabonni | last post by:
I want to check each button groups and save the checked value into a 2 dimensional array. But, it doesn't work. Could anyone tell me what's wrong with my code. My code is as follow: <html> <body> <script language="javascript"> <!-- var temp = new Array(2) var status = new Array();
26
9570
by: JGH | last post by:
How can I check if a key is defined in an associative array? var users = new array(); users = "Joe Blow"; users = "John Doe"; users = "Jane Doe"; function isUser (userID) { if (?????)
2
1618
by: CR | last post by:
having a problem with the final strcpy of filename from *argv into a structure containing an array with 20 elements called fname It seems that strcpy & strncpy aren't stopping after null is found but appending other trash overwriting the array possibly? Any help would be appreciated! (if you need all the code let me know) int main(int argc,...
11
3022
by: Richard Meister | last post by:
Hi, I'd like to define several constants and make sure that all of them are smaller than a given other constant. I thought this could be done by a simple macro. Something like this: #define MAX 999 #define DEF_CHECKED_VAL( name, value) #if (value < MAX) \ #define name MAX \
5
11868
by: Eli | last post by:
Hi, I want to check whether a value is a scalar. A scalar can be: - None (null) - string - number (integer, float) - boolean How can I validate a value is one of these types? I care about the value only, and not its class methods.
14
2515
by: serge calderara | last post by:
Dear all, What is the proper way to check if two object are equal ? I do not mean equal on Object type only but also object value's thnaks for help regards serge
9
2836
by: chutsu | last post by:
hi I got a simple program, and I was wondering how do you check if the string in an array = a string. For example if I put "APPLE" in array Array then how can I check it with a if statement. if (Array == 'APPLE'){ do something; } or do I need to use a different method to check?
173
7961
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc. OTOH, if you're allocating a gigabyte for a large array, this might fail, so you should definitely check for a NULL return.
4
2980
by: jgendr2 | last post by:
So here is my problem I do not know if there is another way to solve this without using arrays....but I am assuming that I DO need to use arrays....Anyways FIRST ARRAY (SINGLE): $results = array($question1,$question2,$question3); SECOND ARRAY (MULTI-DIMENSIONAL) $baseball = array( array("male","female"), array("right","middle"),...
0
7416
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7676
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7932
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7442
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5347
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.