|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I am creating a page for nomination and want to let the information
pass if any field are filled out, but if none are filled out, a message will appear. I can't get the check to happen on multiple fields though. Here is what I have: if ($nominee_first_name !=='' && $nominee_middle_initial !=='' && $nominee_last_name !=='') What happens is that if all fields have content, the page passes, and all I care about is that there is something entered in at least one field. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Nov 6, 4:50 pm, mtuller <mitul...@gmail.com> wrote:
> I am creating a page for nomination and want to let the information > pass if any field are filled out, but if none are filled out, a > message will appear. I can't get the check to happen on multiple > fields though. > > Here is what I have: > if ($nominee_first_name !=='' && $nominee_middle_initial !=='' && > $nominee_last_name !=='') > > What happens is that if all fields have content, the page passes, and > all I care about is that there is something entered in at least one > field. Replace && with || |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Nov 6, 4:15 pm, Darko <darko.maksimo...@gmail.com> wrote:
> On Nov 6, 4:50 pm, mtuller <mitul...@gmail.com> wrote: > > > I am creating a page for nomination and want to let the information > > pass if any field are filled out, but if none are filled out, a > > message will appear. I can't get the check to happen on multiple > > fields though. > > > Here is what I have: > > if ($nominee_first_name !=='' && $nominee_middle_initial !=='' && > > $nominee_last_name !=='') > > > What happens is that if all fields have content, the page passes, and > > all I care about is that there is something entered in at least one > > field. > > Replace && with || Just expanding on Darko's answer - && means 'if condition 1 and condition 2 are true'. || means 'if at least one condition is true'. Both can be used with more than two conditions as well. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Nov 6, 10:15 am, Darko <darko.maksimo...@gmail.com> wrote:
> On Nov 6, 4:50 pm, mtuller <mitul...@gmail.com> wrote: > > > I am creating a page for nomination and want to let the information > > pass if any field are filled out, but if none are filled out, a > > message will appear. I can't get the check to happen on multiple > > fields though. > > > Here is what I have: > > if ($nominee_first_name !=='' && $nominee_middle_initial !=='' && > > $nominee_last_name !=='') > > > What happens is that if all fields have content, the page passes, and > > all I care about is that there is something entered in at least one > > field. > > Replace && with || Sorry, the subject of this is wrong. I don't want to check if any fields are empty. I want to check if all are empty. That's why I have &&. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
mtuller wrote:
> On Nov 6, 10:15 am, Darko <darko.maksimo...@gmail.com> wrote: >> On Nov 6, 4:50 pm, mtuller <mitul...@gmail.com> wrote: >> >>> I am creating a page for nomination and want to let the information >>> pass if any field are filled out, but if none are filled out, a >>> message will appear. I can't get the check to happen on multiple >>> fields though. >>> Here is what I have: >>> if ($nominee_first_name !=='' && $nominee_middle_initial !=='' && >>> $nominee_last_name !=='') >>> What happens is that if all fields have content, the page passes, and >>> all I care about is that there is something entered in at least one >>> field. >> Replace && with || > > Sorry, the subject of this is wrong. I don't want to check if any > fields are empty. I want to check if all are empty. That's why I have > &&. > if (empty($nominee_first_name) && empty($nominee_middle_initial) && empty($nominee_last_name)) -- Posted via a free Usenet account from http://www.teranews.com |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Nov 6, 11:20 am, Justin Koivisto <justin.koivi...@gmail.com> wrote:
> mtuller wrote: > > On Nov 6, 10:15 am, Darko <darko.maksimo...@gmail.com> wrote: > >> On Nov 6, 4:50 pm, mtuller <mitul...@gmail.com> wrote: > > >>> I am creating a page for nomination and want to let the information > >>> pass if any field are filled out, but if none are filled out, a > >>> message will appear. I can't get the check to happen on multiple > >>> fields though. > >>> Here is what I have: > >>> if ($nominee_first_name !=='' && $nominee_middle_initial !=='' && > >>> $nominee_last_name !=='') > >>> What happens is that if all fields have content, the page passes, and > >>> all I care about is that there is something entered in at least one > >>> field. > >> Replace && with || > > > Sorry, the subject of this is wrong. I don't want to check if any > > fields are empty. I want to check if all are empty. That's why I have > > &&. > > if (empty($nominee_first_name) && empty($nominee_middle_initial) && > empty($nominee_last_name)) > > -- > Posted via a free Usenet account fromhttp://www.teranews.com I had tried that too. Except I used !empty. if (!empty($nominee_first_name) && !empty($nominee_middle_initial) && ! empty($nominee_last_name)) { // If not empty, insert into database $nominee_field_query = "INSERT INTO faculty_nominations.nominations (nominee_first_name, nominee_middle_initial, nominee_last_name, nominee_comments) values ('$nominee_first_name', '$nominee_middle_initial', '$nominee_last_name', '$nominee_comments')"; // update database with infromation submitted $db_query = mysqli_query ($db_connect, $nominee_field_query); } else { echo 'The fields are empty'; } When I submit, if I have data in one field, but not in all, it displays "The fields are empty". I want it to submit into the database if any fileds are filled in, but not if there are no fields filled in. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
mtuller <mituller@gmail.com> wrote in
news:1194370693.692490.11330@19g2000hsx.googlegrou ps.com: > When I submit, if I have data in one field, but not in all, it > displays "The fields are empty". I want it to submit into the database > if any fileds are filled in, but not if there are no fields filled in. but one post ago you said: "Sorry, the subject of this is wrong. I don't want to check if any fields are empty. I want to check if all are empty. That's why I have &&." So decide what exactly you are trying to do, and then pick either of the solutions posted. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Nov 6, 11:41 am, Good Man <he...@letsgo.com> wrote:
> mtuller <mitul...@gmail.com> wrote innews:1194370693.692490.11330@19g2000hsx.googlegr oups.com: > > > When I submit, if I have data in one field, but not in all, it > > displays "The fields are empty". I want it to submit into the database > > if any fileds are filled in, but not if there are no fields filled in. > > but one post ago you said: > > "Sorry, the subject of this is wrong. I don't want to check if any > fields are empty. I want to check if all are empty. That's why I have > &&." > > So decide what exactly you are trying to do, and then pick either of the > solutions posted. Ok. I see where it sounds like I am saying different things, but I am not. Let me try again... I want to check to see if ALL fields are empty, and if they are, the form is not submitted into the database. If any of the fields have data though, I want it to be submitted. That is why I am checking with &&. If $nominee_first_name AND $nominee_middle_initial AND $nominee_last_name are all empty, echo "The fields are empty". If any are filled in, then submit to the database. Hope that explains better. |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
mtuller <mituller@gmail.com> wrote in
news:1194372034.748781.192620@o38g2000hse.googlegr oups.com: >> So decide what exactly you are trying to do, and then pick either of >> the solutions posted. > > Ok. I see where it sounds like I am saying different things, but I am > not. Let me try again... > > I want to check to see if ALL fields are empty, and if they are, the > form is not submitted into the database. If any of the fields have > data though, I want it to be submitted. That is why I am checking with > &&. If $nominee_first_name AND $nominee_middle_initial AND > $nominee_last_name are all empty, echo "The fields are empty". If any > are filled in, then submit to the database. > > Hope that explains better. perfect! so you know what you want to do, does this mean you've chosen a solution from the thread, or can create your own? you've said exactly what you want to do above (even in code term, no less) so just put it together!!! |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On Nov 6, 12:12 pm, Good Man <he...@letsgo.com> wrote:
> mtuller <mitul...@gmail.com> wrote innews:1194372034.748781.192620@o38g2000hse.google groups.com: > > >> So decide what exactly you are trying to do, and then pick either of > >> the solutions posted. > > > Ok. I see where it sounds like I am saying different things, but I am > > not. Let me try again... > > > I want to check to see if ALL fields are empty, and if they are, the > > form is not submitted into the database. If any of the fields have > > data though, I want it to be submitted. That is why I am checking with > > &&. If $nominee_first_name AND $nominee_middle_initial AND > > $nominee_last_name are all empty, echo "The fields are empty". If any > > are filled in, then submit to the database. > > > Hope that explains better. > > perfect! > > so you know what you want to do, does this mean you've chosen a solution > from the thread, or can create your own? you've said exactly what you want > to do above (even in code term, no less) so just put it together!!! THEY DON'T WORK!!!! Do you think I am posting for my health?! |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
In our last episode,
<1194372034.748781.192620@o38g2000hse.googlegroups .com>, the lovely and talented mtuller broadcast on comp.lang.php: > On Nov 6, 11:41 am, Good Man <he...@letsgo.com> wrote: >> mtuller <mitul...@gmail.com> wrote innews:1194370693.692490.11330@19g2000hsx.googlegr oups.com: >> >> > When I submit, if I have data in one field, but not in all, it >> > displays "The fields are empty". I want it to submit into the database >> > if any fileds are filled in, but not if there are no fields filled in. >> >> but one post ago you said: >> >> "Sorry, the subject of this is wrong. I don't want to check if any >> fields are empty. I want to check if all are empty. That's why I have >> &&." >> >> So decide what exactly you are trying to do, and then pick either of the >> solutions posted. > Ok. I see where it sounds like I am saying different things, but I am > not. Let me try again... > I want to check to see if ALL fields are empty, and if they are, the > form is not submitted into the database. Good grief, don't they teach programmers any symbolic logic anymore? All fields empty is the same as not(one of them is filled in). > If any of the fields have data though, I want it to be submitted. That is > why I am checking with &&. But obviously that is wrong. > If $nominee_first_name AND $nominee_middle_initial AND $nominee_last_name > are all empty, echo "The fields are empty". If $nominee_first_name AND $nominee_middle_initial AND $nominee_last_name are all empty = If not($nominee_first_name is empty OR $nominee_middle_initial is empty OR $nominee_last_name is empty) > If any are filled in, then submit to the database. > Hope that explains better. -- Lars Eighner <http://larseighner.com/> <http://myspace.com/larseighner> Countdown: 440 days to go. What do you do when you're debranded? |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
..oO(mtuller)
>Ok. I see where it sounds like I am saying different things, but I am >not. Let me try again... > >I want to check to see if ALL fields are empty, and if they are, the >form is not submitted into the database. If any of the fields have >data though, I want it to be submitted. That is why I am checking with >&&. If $nominee_first_name AND $nominee_middle_initial AND >$nominee_last_name are all empty, echo "The fields are empty". If any >are filled in, then submit to the database. > >Hope that explains better. The solution was already posted: <news:1194365743.911855.266720@50g2000hsm.googlegr oups.com> Micha |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
On Nov 6, 1:14 pm, Michael Fesser <neti...@gmx.de> wrote:
> .oO(mtuller) > > >Ok. I see where it sounds like I am saying different things, but I am > >not. Let me try again... > > >I want to check to see if ALL fields are empty, and if they are, the > >form is not submitted into the database. If any of the fields have > >data though, I want it to be submitted. That is why I am checking with > >&&. If $nominee_first_name AND $nominee_middle_initial AND > >$nominee_last_name are all empty, echo "The fields are empty". If any > >are filled in, then submit to the database. > > >Hope that explains better. > > The solution was already posted: > > <news:1194365743.911855.266720@50g2000hsm.googlegr oups.com> > > Micha Just my luck today. The link you gave me says it can't be found. |
|
|
|
#14 |
|
Messages: n/a
Hébergeur: |
..oO(mtuller)
>On Nov 6, 1:14 pm, Michael Fesser <neti...@gmx.de> wrote: >> >> The solution was already posted: >> >> <news:1194365743.911855.266720@50g2000hsm.googlegr oups.com> > >Just my luck today. The link you gave me says it can't be found. It was the first reply in this thread from Darko: | Replace && with || Micha |
|
|
|
#15 |
|
Messages: n/a
Hébergeur: |
mtuller <mituller@gmail.com> wrote in news:1194384049.997043.5250@
19g2000hsx.googlegroups.com: > On Nov 6, 1:14 pm, Michael Fesser <neti...@gmx.de> wrote: >> .oO(mtuller) >> >> >Ok. I see where it sounds like I am saying different things, but I am >> >not. Let me try again... >> >> >I want to check to see if ALL fields are empty, and if they are, the >> >form is not submitted into the database. If any of the fields have >> >data though, I want it to be submitted. That is why I am checking with >> >&&. If $nominee_first_name AND $nominee_middle_initial AND >> >$nominee_last_name are all empty, echo "The fields are empty". If any >> >are filled in, then submit to the database. >> >> >Hope that explains better. >> >> The solution was already posted: >> >> <news:1194365743.911855.266720@50g2000hsm.googlegr oups.com> >> >> Micha > > Just my luck today. The link you gave me says it can't be found. > Only because it's sooooo very painful to watch you struggle... note that you know exactly what you want, in fact up above you've specified it in coding terms!!!!!! if(($nominee_first_name=="") && ($nominee_middle_initial=="") && ($nominee_last_name=="")) { echo "The fields are empty."; } else { enterTheDamnCode(); } Notice how the clause is EXACTLY WHAT YOU WERE SAYING IN PLAIN ENGLISH UP ABOVE!!!!!! Now, to add a bit of insight as to why this got confusing for you - at first you were checking for NOT empty: if ($nominee_first_name !=='' && $nominee_middle_initial !=='' && $nominee_last_name !=='') .... and in that case, you would use || ("or") and reverse the call: if ($nominee_first_name !='' || $nominee_middle_initial !='' || $nominee_last_name !='') { enterTheDamnCode(); } else { echo "The fields are empty."; } |
|
|
|
#16 |
|
Messages: n/a
Hébergeur: |
Michael Fesser wrote:
> .oO(mtuller) > > >> On Nov 6, 1:14 pm, Michael Fesser <neti...@gmx.de> wrote: >> >>> The solution was already posted: >>> >>> <news:1194365743.911855.266720@50g2000hsm.googlegr oups.com> >>> >> Just my luck today. The link you gave me says it can't be found. >> > > It was the first reply in this thread from Darko: > > | Replace && with || > > Micha > ..... Just a note: I've switched to using AND and OR instead of && and ||. Seems a little clearer to me when I read the code. -- ***************************** Chuck Anderson • Boulder, CO http://www.CycleTourist.com Nothing he's got he really needs Twenty first century schizoid man. *********************************** |
|
|
|
#17 |
|
Messages: n/a
Hébergeur: |
..oO(Chuck Anderson)
>.... Just a note: I've switched to using AND and OR instead of && and >||. Seems a little clearer to me when I read the code. No problem with that, just keep in mind that AND/OR have a lower precedence than &&/||. Micha |
|
![]() |
| Outils de la discussion | |
|
|