473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Check Box and Arrays

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 1724
pbmods
5,821 Expert 4TB
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
Sorry about not posting the code correctly.
Aug 8 '07 #3
kovik
1,044 Expert 1GB
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 Expert 4TB
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
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 Expert 1GB
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 Expert 1GB
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
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...
15
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>...
26
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
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...
11
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...
5
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...
14
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
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...
173
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....
4
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 =...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.