Hi all
I want to specify an OR condition in an if statement. Can anyone please tell me how this can be done.
I've tried this but it does not work
[PHP]<? if (($add!=1) or (!empty($row["Bkg_Renewal_Dt"])))
{
echo '<tr>';
echo '<td class="hr">';echo htmlspecialchars("Renewal Date")." " ;echo '</td>';?>
<td class="dr"><input type="text" readonly name="Bkg_Renewal_Dt" value="<? echo str_replace('"', '"', trim($row["Bkg_Renewal_Dt"])) ?>"><input type="button" value="Cal" onclick="displayCalendar(document.forms[0].Bkg_Renewal_Dt,'yyyy-mm-dd',this)">
<? echo '</td>';
echo '</tr>';
} ?>[/PHP]
Thanks
5 1469
Hi all
I want to specify an OR condition in an if statement. Can anyone please tell me how this can be done.
I've tried this but it does not work
[PHP]<? if (($add!=1) or (!empty($row["Bkg_Renewal_Dt"])))
{
echo '<tr>';
echo '<td class="hr">';echo htmlspecialchars("Renewal Date")." " ;echo '</td>';?>
<td class="dr"><input type="text" readonly name="Bkg_Renewal_Dt" value="<? echo str_replace('"', '"', trim($row["Bkg_Renewal_Dt"])) ?>"><input type="button" value="Cal" onclick="displayCalendar(document.forms[0].Bkg_Renewal_Dt,'yyyy-mm-dd',this)">
<? echo '</td>';
echo '</tr>';
} ?>[/PHP]
Thanks
Replace the if part with this:
if (($add!=1)||(!empty($row["Bkg_Renewal_Dt"])))
**Note the character is a pipe character ||
Hope this helps
Alternatively, you can do this: - if (! (($add == 1) && empty($row['Bkg_Renewal_Dt'])))
if you want to save a CPU cycle or two (note also single quotes around 'Bkg_Renewal_Dt').
Also, if empty($row['Bkg_Renewal_Dt']) is more likely to occur, it should come before ($add == 1) in the conditional to encourage short-circuits.
Hi
Is there something wrong with the code below. I've tried the solution you proposed but it is not working. If the variable $add is not equal to one and the renewal date contains a value then only should the textbox for the renewal date be displayed otherwise if add==1 or if the renewal date does not contain any value the textbox to edit the renewal date should not be displayed
[PHP]
some other codes
</tr>
if (! (($add == 1) && (empty($row['Bkg_Renewal_Dt'])))) //if not adding and if renewal date is not empty display renewal dt else not
{ ?>
<tr>
<td class="hr"><? echo htmlspecialchars('Renewal Date')." " ?></td>
<td class="dr"><input type="text" readonly name="Bkg_Renewal_Dt" value="<? echo str_replace('"', '"', trim($row['Bkg_Renewal_Dt'])) ?>"><input type="button" value="Cal" onclick="displayCalendar(document.forms[0].Bkg_Renewal_Dt,'yyyy-mm-dd',this)">
</td>
</tr>
<? } ?>
<tr>
some other codes
[/PHP]
Thanks for your help
Hi
Is there something wrong with the code below. I've tried the solution you proposed but it is not working. If the variable $add is not equal to one and the renewal date contains a value then only should the textbox for the renewal date be displayed otherwise if add==1 or if the renewal date does not contain any value the textbox to edit the renewal date should not be displayed
[PHP]
some other codes
</tr>
if (! (($add == 1) && (empty($row['Bkg_Renewal_Dt'])))) //if not adding and if renewal date is not empty display renewal dt else not
{ ?>
<tr>
<td class="hr"><? echo htmlspecialchars('Renewal Date')." " ?></td>
<td class="dr"><input type="text" readonly name="Bkg_Renewal_Dt" value="<? echo str_replace('"', '"', trim($row['Bkg_Renewal_Dt'])) ?>"><input type="button" value="Cal" onclick="displayCalendar(document.forms[0].Bkg_Renewal_Dt,'yyyy-mm-dd',this)">
</td>
</tr>
<? } ?>
<tr>
some other codes
[/PHP]
Thanks for your help
I noticed that you separated some parts of the codes...
Can you put all your codes inside the php tag like this:
<?php
codes....
?>
Please don't forget to echo some html tags over there....
Please write your programs in a structured manner so that you can see what line causes the error....
If there are still errors please post the error...
Me too waiting for your original coding......
Sign in to post your reply or Sign up for a free account.
Similar topics
by: news |
last post by:
I'm trying out the Zend Development Environment 4, and for the most
part I like it, except for two things.
It seems to think certain lines that are perfectly valid are bugs. Like
this:
while...
|
by: Chris |
last post by:
I have tableA, defined as:
field1 varchar2(10),
field2 varchar2(10),
field3 varchar2(10)
I have host variables defined as:
v1 pic x(10) varying
v2 pic x(10) varying
|
by: mr_mach7 |
last post by:
I have a situation in which I want to dynamically build a SQL
statement based upon criteria. The statement would contain different
fields depending upon the criteria. I created a Stored Procedure...
|
by: Daniel Bass |
last post by:
Using VC#.Net, I want to take a statement, that loosely follows the rules of
an SQL'a "WHERE" statement, and determine whether that statement is true or
false.
For example:
( ( Head = 'abc')...
|
by: Lisa J. |
last post by:
Heloe
I would like to be able to pass a condition of an IF statement as parameter as follow
aStr=” (A=1) and (B=2)”
if aFunc(“aStr”) then
….
End if
|
by: Ben R. |
last post by:
In an article I was reading
(http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/),
I read the following:
"The ending condition of a VB.NET for loop is evaluated only once,...
|
by: Sorin Schwimmer |
last post by:
I am thinking on something in the following form:
<code>
import time
import thread
delay=True
def fn()
global delay
|
by: jimc52 |
last post by:
Hello Everyone: I am hoping one of the gurus here will give me some help.
I have designed a form with some check boxes. I put the checkboxes there on the form so later I could use them as flags on...
|
by: Ely |
last post by:
Can some one write me the code in Visual Basic for an expretion
similar to the Where Condition to open a report? I can't use the
Where Condition because it pop up a message of Microsoft database...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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 projectplanning, coding, testing,...
| |