I wish to check if a variable (I am pulling the variable as mysql_fetch_array) contains the number 2008 in it. If so it is displayed.

Now I have the display working fine but it displays everything and I want to optimize it to just show the variables containing 2008.

Any ideas?

Thanks, Regards X.

Umm..

if($row['col1'] == "2008") {
//print
} //else do nothing

If the record in the table has more than 2008, for example, some text with it, you can try it this way.

<?php
$str = "test - 2008 is as boring as 2007";
if(strstr($str,"2008")) {
	echo "2008 found!";
} else {
	echo "2008 not found!";
}
?>
Comments
Always helpful as usual :)

I just solved it using stristr and then found your solution (never got notified of your message)whats the difference between the functions?

Thanks once again nav.

stristr does the same as strstr. But stristr is case-insensitive. ie., stristr("This is a test","IS"); will return true since "IS" is found in "This". Whereas, strstr("This is a test","IS"); will return false (since "IS" doesn't match with "is").

Cheers,
Nav

Ahh ok thanks nav, genious as usual ;)

On to the next problem XD

If you get a chance to look at my double click problem (requires 2 clicks to be updated) I think that covers everything I require for this project XD

I read your post above with great interest. I have a phpBB forum and am the most beginning of beginners. I have what seems to me an easy question for someone beyond my "knowledge". I am trying to construct a simple if then else statement that I can wrtie that will test for the "is the user logged in " variable (which I don't know) - test for true or false and allow me to display a guest message.

This is so simple Im a little embarassed (lol) but I would appreciate some help.

Thanks,

This is the "bones" of what I'm trying to.

$logged = variable_name_that contains_login_value

<?php
if   $logged = variable_name_that contains_login_value
display welcome/signup banner;
} else {
Do nothing;
}
?>

Edited 3 Years Ago by happygeek: fixed formatting

You should post your problem in a new thread but anyways.

Few minor things wrong with your code:

<?php
if ($logged == "variable_name_that contains_login_value") 
display welcome/signup banner;
} 
?>

Hope that helps

Regards, X

You should post your problem in a new thread but anyways.

Few minor things wrong with your code:

<?php
if ($logged == "variable_name_that contains_login_value") 
display welcome/signup banner;
} 
?>

Hope that helps

Regards, X

Thanks for the reply it is much appreciated. My only remaining questions are:

1. Is the correct name of the variable $logged
2. What values do it contain or return

Thanks again

Umm.. There are some things you need to know before 'creating' a variable. A variable can't start with an integer. For example, $123variable is not a valid variable name. More about it here..
http://nl2.php.net/language.variables
And $logged will have the value that you assigned to it. For example,

<?php
$logged = "yes";
if($logged == "no") {
    echo "Not logged in";
} else {
  echo "Logged in..";
}

Nav has answered your question.

If you still dont understand, cut out a section of your code and we will try to help you.

Nav has answered your question.

If you still dont understand, cut out a section of your code and we will try to help you.

First Nav33n I thank you very much for your patience and professionalism of your response to my inquiry - It is greatly appreciated. A cursory review of this forum and your responses clearly indicates you are a professional with a focus on helpfulness, knowledge and professionalism.

Ominx I have no idea who you are, apparently an entity found all to often on these types of forum - a person who is all to willing to butt in in an unhelpful manner in an effort to effect some type of what you see as "authority". You are unequivocally in error. My question is not answered. It may be that I did not frame the questions properly and I accept full responsibility for that but the fact is the question I sought was not answered - I have no code example to send - that is the issue - I thought I might focus in on problem I had with Nav33n's assistance. Clearly he is a person of sufficient quality and knowledge to solve questions of this type without input form someone who, it seems, whose only interest is to exert control where they have none. A basic read of my question was to test the contents of the variable, which variable, what are it's contents - so that I could display a menu. Nav33n understood that - apparently you could not.

I will find another forum - where there may be someone who can assist in a helpful, professional manner - like Nav33n did without having to put up with people whose best "quality" is to participate in a wholly unconstructive manner. It appears you did not read or comprehend my question - even so Nav33n could clearly handle this elementary questions as I can see he has handled questions of much higher complexity without your interjection.

It is sad to see that all too many forums have people like yourself who, rather than participate in a constructive manner, stand on the sidelines and interject smart-aleck, unhelpful, off-point asides.

My point in coming here is that 1.) I have a programmer 2.) I have with little knowledge but have made minor additions to my forum myself (at a savings) and am seeking a forum that can assist me in my growth to execute basic programming projects. Rather than waste time on processes and procedures that do not help. You are likely not to agree with my assessment but even you can see that Nav33n does not lack the tools to direct the assistance effort without your uninformed input - he had a grasp of my question - why do you feel the need to get involved?

Once again Nav33n - thanks for your help I appreciate it - clearly you are a person who should occupy a higher position on this board - perhaps then you could institute processes and procedures that would result in not having assistance interrupted by others. I am sure I can find assistance on these elementary programming matters elsewhere. GL to you.

Jon

Jon

Its pretty simple.

People are expected to act and in a respectful and intelligent manner.

Which you have neither of.

Nav and myself both have put examples forward for you, hence why I said to post your code.

If you could not get your problem across that was due to your own stupidity.

Regards, X

PS: Nav great bloke and should not be wasting his time with people like you, you are lucky he even helped. (1 you posted in my thread when i told you to post your own, 2 even once you did post you were disrespectful and unintelligent)

Guys! take it easy.. There is some kinda misunderstanding here.. :) Since the problem is solved, lets stop it right there and not make this a fight thread..
Cheers,
Nav

I read throught whole tread since it started. It is very interesting and educational, however I think on the end it went little out of usual friendly discussion

@Merlin333 I'm sorry, but I see no reason why you wrote your post in such negative manner toward OmniX. In his post

Nav has answered your question.
If you still dont understand, cut out a section of your code and we will try to help you.

he wasn't trying to attack you or say something bad. OmniX just tried to find out if there is anything else where they may assist you.

@OmniX your later post should not be necesary in the tone as you made it. Simple "sorry if you misundestand my post" and "is there anything else we can do for you" would do it.

For the future re-read the post few times if on the first go you think the answer is out of friendly standards, you may find that you actualy misinterpreted the content. If there still any issues you are free to discuse it with me

Peter

You are right.

But like the saying goes
"Shame on you once shame on me twice"

I was trying to help the child and he abuses me?

Im not gonna stand for that in the real world let alone on the internet.

Hope you understand.

Plus I did it in an Intellectual actual manner imo rather than flaming him as I would have usually done, so im proud for my own self control :)

Anyways prolly best if you can permenant close this thread so no one else can post anymore comments :)

First I appreciate the additional comments.

My response, perhaps differently than you assess it, was a reaction to being cut off by a second party who obviously had not read the question, seemed to terminate the discussion - while Nav33 had the situation throughly in hand. I accept that my statement of the problem may have created some dissonance but I do not accept Omni sending me a direct threat via PM as a result of my reaction to his interruption.

This kind of conduct is childish, unprofessional, illegal and disrespectful of what I saw as Nav33's proven (from reviews of other situations where he has provided help) ability to be helpful, knowledgeable and professional . There is nothing I said that would permit OmniX, who in my view added nothing but an additional layer of unnecessary confusion to issue a physical threat to me because he didn't like my statement. My assessment of the tone and content of everyone else who has communicated in this question is that it is proper, and professional - My assessment of Omnix is the opposite of the other members. Adults can and should have the ability to disagree without threats. Simply put, I will not stand for people to issue physical threats via the internet under the guise of "help".

I am not a programmer and sought only to get an answer to something most people indicate is simple and that I should be able to get an answer to and do myself. Certainly my statement of the issue could have been more accurate.

Once again thanks to you all except for OmniX. I have responded to his threat and cc'd his superiors.

J

Peter_budo - I guess more properly stated I was also trying to identify the actual variable name, its state (contents).

My intention was to create an if then else statement that would detect if the user was a guest or not (logged on or not). If not logged on nothing would be done, if logged on a message would be displayed.

Part of my confusion is that I was aware of a variable named $user_data[?] and have seen it in code snippets. I was trying to determine the correct variable and it's contents. Nav's original response (to my eyes) while displaying the if structure did not clarify what was the correct name of the variables involved.

SORRY my time had expired on edits:

First I appreciate the additional comments.

My response, perhaps differently than you assess it, was a reaction to being cut off by a second party who obviously had not read the question, seemed to terminate the discussion - while Nav33 had the situation throughly in hand. I accept that my statement of the problem may have created some dissonance but I do not accept Omni sending me a direct threat via PM as a result of my reaction to his interruption.

This kind of conduct is childish, unprofessional, illegal and disrespectful of what I saw as Nav33's proven (from reviews of other situations where he has provided help) ability to be helpful, knowledgeable and professional . There is nothing I said that would permit OmniX, who in my view added nothing but an additional layer of unnecessary confusion to issue a physical threat to me because he didn't like my statement. My assessment of the tone and content of everyone else who has communicated in this question is that it is proper, and professional - My assessment of Omnix is the opposite of the other members. Adults can and should have the ability to disagree without threats. Simply put, I will not stand for people to issue physical threats via the internet under the guise of "help".

I am not a programmer and sought only to get an answer to something most people indicate is simple and that I should be able to get an answer to and do myself. Certainly my statement of the issue could have been more accurate.

Clearly his remark "Plus I did it in an Intellectual actual manner imo rather than flaming him as I would have usually done, so im proud for my own self control" Shows rather a lack of intellect and self control. I do not think an adult boasting such qualities would send letters threating to kick someones head in. To write this publicly, then send me a threat shows he is a best a delusional, ignorant liar. Few would find what he wrote intellectual. I will say this I did not threaten him and while my criticism was harsh he did not address the elements of my critique - he issued a threat. I managed a marketing department for Montgomery Ward which at time was one of the largest corporations in the world. There are NO situations where an associate of the company,regardless of their rank, would issue a threat to a customer - period. That he would write the ameliorative remarks above as a cover then brags that he would usually "flame" complaints, shows his true character and intention and gives foundation for my original assessment of his intent.

Once again thanks to you all except for OmniX. In my view a person whose carries such a chip on his shoulder is not prepared to handle what I see as a knowledge-based customer service function - what threaten everyone who doesn't like the service - come on. I have responded to his threat and cc'd his superiors (I have copied these pages and send a link to them also). It is a shame that the other professionals here have to put with this.

Finally, my intent is not to "flame" anyone - I work in an environment where professionals have the intelligence and skill to directly state their issue. For the purpose of accurately identifying and correcting the issue and for that purpose alone - not to create some grade school war of words. While OmniX makes threats he claims I'd have to face in the real world - in the real world, in a business, when faced with opposition, difference of ideas, disagreement and lacking of skill to make your case in a manner more effective than threats - you probably won't remain employable long. As to OminX remarks as to "intellect" which he apparently sees as schoolyard namecalling, I will let the content of the dialog stand for itself.

J

Peter_budo - I guess more properly stated I was also trying to identify the actual variable name, its state (contents).

My intention was to create an if then else statement that would detect if the user was a guest or not (logged on or not). If not logged on nothing would be done, if logged on a message would be displayed.

Part of my confusion is that I was aware of a variable named $user_data[?] and have seen it in code snippets. I was trying to determine the correct variable and it's contents. Nav's original response (to my eyes) while displaying the if structure did not clarify what was the correct name of the variables involved.

This question has already been answered. Start a new discussion instead.