473,809 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If statement question

Hi there,

I have the following code:

echo "\n <address>";
if ($entry_info[location] and $entry_info[location] != '') {
echo "\n ".stripslashes( $entry_info[location]).".,";
}
if ($entry_info[address1] and $entry_info[address1] != '' ) {
echo "\n ".stripslashes( $entry_info[address1]);
}
if ($entry_info[address2] and $entry_info[address2] != '' ) {
echo ',';
echo "\n ".stripslashes( $entry_info[address2]);
}
If the mysql database does not have the field populated I do not want the .,
to appear in the address.
What can I put to show not equal to any data in the database.

Thanks in advance for your help.
Smriti
Jul 17 '05 #1
3 3399

On 8-Dec-2003, "Smriti Dev" <sm********@uto ronto.ca> wrote:
I have the following code:

echo "\n <address>";
if ($entry_info[location] and $entry_info[location] != '') {
echo "\n ".stripslashes( $entry_info[location]).".,";
}
if ($entry_info[address1] and $entry_info[address1] != '' ) {
echo "\n ".stripslashes( $entry_info[address1]);
}
if ($entry_info[address2] and $entry_info[address2] != '' ) {
echo ',';
echo "\n ".stripslashes( $entry_info[address2]);
}
If the mysql database does not have the field populated I do not want the
.,
to appear in the address.
What can I put to show not equal to any data in the database.


If the location column is a CHAR, it is fixed length and the database will
return that length of spaces. Comparing it to '' will not work. You could
compare to ' ' (the appropriate number of spaces) or use trim() to
remove the spaces.

You should be coding quotes or apostrophies around your column names (unless
you've defined them as constants or they are in a double quoted string), for
example:
if ($entry_info['location'] and trim($entry_inf o['location'])!='')

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@wil lglen.net (it's reserved for spammers)
Jul 17 '05 #2
"Smriti Dev" <sm********@uto ronto.ca> wrote in message news:<Hp******* *@campus-news-reading.utoront o.ca>...
Hi there,

I have the following code:

echo "\n <address>";
if ($entry_info[location] and $entry_info[location] != '') {
echo "\n ".stripslashes( $entry_info[location]).".,";
}
if ($entry_info[address1] and $entry_info[address1] != '' ) {
echo "\n ".stripslashes( $entry_info[address1]);
}
if ($entry_info[address2] and $entry_info[address2] != '' ) {
echo ',';
echo "\n ".stripslashes( $entry_info[address2]);
}
If the mysql database does not have the field populated I do not want the .,
to appear in the address.
What can I put to show not equal to any data in the database.

Thanks in advance for your help.
Smriti

Hi Smriti,

I assume the location field in your database is string.

There are two possibilities:-

1. If you declare the field as *NULL-allowed field*

You can check for NULL value with is_null($entry_ info['location']) function

2. If the field in database is declared as *NOT NULL field*
You can check for empty string $entry_info['location'] ==""
I think better way to do this checking is by merging these two conditions
with a single statement:

empty($entry_in fo['location'])

It will return false only when your location field is populated and non empty.

-- Rahul
Jul 17 '05 #3
"Smriti Dev" a écrit le 08/12/2003 :
I have the following code:

echo "\n <address>";
if ($entry_info[location] and $entry_info[location] != '') {
echo "\n ".stripslashes( $entry_info[location]).".,";
}
if ($entry_info[address1] and $entry_info[address1] != '' ) {
echo "\n ".stripslashes( $entry_info[address1]);
}
if ($entry_info[address2] and $entry_info[address2] != '' ) {
echo ',';
echo "\n ".stripslashes( $entry_info[address2]);
}
If the mysql database does not have the field populated I do not want the .,
to appear in the address.
What can I put to show not equal to any data in the database.


Sorry I don't get your question... Maybe because it's late...
You statement if ($entry_info[adress2]) is not very clear and clean,
what do you want to test there? Do you mean isset()?

--
Have you read the manual?
http://www.php.net/manual/en/

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4411
by: Greg Ofiesh | last post by:
Anyone who can help, I have two tables T1 and T2. T1 has fields K1 and F2 and T2 has fields K2 and F1. F1 is the foreign key relating to K1 and F2 is the foreign key relating to K2. My initial question has been how can I add a row to both tables with accurate Fx values in one SQL INSERT statement? I have been told it cannot be done.
94
13914
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it would be more orthogonal if a method could only have one return statement. --
9
2367
by: Michael | last post by:
Hi all, I would like to get people's opinion about executing SQL statements in C# (or any other .NET language really). I used to create my SQL statement by building a string and replacing single quote with two single quotes. Sometimes, I used SqlParameter. Maybe, I'm a bit lazy when I build the SQL string. Should I always use SqlParameters? What are the advantages/disadvantages between building SQL string and using SqlParameter? Does...
7
2704
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable>
1
3043
by: javedna | last post by:
Can PHP help with the following as I have tried in the MYSQL Forums and cant get any help Thanks Nabz ---------------------------------------- Hi I am developing a PHP MYSQL questionnaire tool. The problem I am having is that of inserting all the answers into the table. The questionnaire is Dynamic so the number of questions can vary. I have a variable that counts them so at the moment there is 75 questions.
26
3239
by: a.mil | last post by:
I am programming for code-speed, not for ansi or other nice-guy stuff and I encountered the following problem: When I have a for loop like this: b=b0; for (a=0,i=0;i<100;i++,b--) { if (b%i) continue; a=1; }
18
7980
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp defintion of "expression" and "statement"? What is the difference between an expression and a statement?
23
2082
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return Result(1) 3. Evaluate SourceElement. 4. Return Result(3). If I understood correctly the following program should alert 'undefined': alert(eval('3;;'));
21
17463
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know), but each answer is given a different point value for each question. For instance, question 1 might ask "Do you like candy?" and if you answer Yes you will get +1, No will earn you -1, and Don't know will net you zero points. The next question might...
10
3574
by: JohnO | last post by:
Hi All, This question is related to iSeries V5R4 and db2. I want to implement an AFTER DELETE trigger to save the deleted rows to an archive table, I initially defined it as a FOR EACH STATEMENT trigger that would insert all the deleted rows in one operation like this: CREATE TRIGGER MyTable_TD
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
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
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.