Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Solving a If condition
Old 10-03-2008, 06:29 PM Solving a If condition
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Hi

I'm trying using the if situation to show a the name of a country and a html table in the following condition:


<html>

<table width="100%" border="0" cellspacing="2" cellpadding="0">

<? if ($country!=" ") { ?>
<tr>
<td width='42%'>
<table width='264' height='26' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td background='images/pict_66.jpg'>

<table width='264' height='26' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='164' align='right' valign='middle'><font face='arial' color='#999999' size='1'><? $lang_country ?>&nbsp;</font></td>
<td width='100' align='left' valign='middle'><font face='arial' size='1' color='#000000'>&nbsp;
<? $country ?>
</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height='2'><img src='images/pict_spacer.gif' width='264' height='2' /></td>
</tr>
</table>
<? } ?>

</html>

But it shows the table without info, when it suppose not show the table either.

thanks
josil is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-03-2008, 06:57 PM Re: Solving a If condition
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Maybe it's because you open the table before the if condition AND the IF condition is met provided the variable is not equal to a single space.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-03-2008, 07:07 PM Re: Solving a If condition
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
I’m not quite sure what you trying to achieve. Is this what your IF condition is supposed to mean?
If $country is set to anything but empty, print the table, otherwise do nothing

If so, then change your condition into:
PHP Code:
if ($country) { 
Anyway I think the main reason you are getting no PHP from your script is because you are using the wrong syntax opener. The correct PHP opening is <?php and closing is ?>. It depends on your server settings, but just to be on the safe side use that instead of <? and ?>.
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)
frofi is offline
Reply With Quote
View Public Profile
 
Old 10-03-2008, 07:13 PM Re: Solving a If condition
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Maybe it's because you open the table before the if condition AND the IF condition is met provided the variable is not equal to a single space.
I think he's only posted a small part of the table construct. If his condition isn't met, the script might continue to another one etc until a condition is met or the table closes with plain HTML outside of script. In other words, the table could be script independent. If it isn't, then you are right and the IF condition should be placed before the table begins.
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)
frofi is offline
Reply With Quote
View Public Profile
 
Old 10-04-2008, 02:02 AM Re: Solving a If condition
Average Talker

Posts: 29
Name: Dave
Trades: 0
The problem with the table is still showing is because you're using html when you should have php print that html so you can have control of when the condition isn't met it doesn't print that code. Right now regardless of whether $country is set or not, those tables are going to be printed.

Last edited by davie_gravy; 10-04-2008 at 02:04 AM..
davie_gravy is offline
Reply With Quote
View Public Profile
 
Old 10-04-2008, 01:09 PM Re: Solving a If condition
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Nope, you can put HTML code inside an IF condition and have render only when the condition is met.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-04-2008, 04:31 PM Re: Solving a If condition
Average Talker

Posts: 29
Name: Dave
Trades: 0
Really? I didn't know that. My bad, should have tested it first.
davie_gravy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Solving a If condition
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29994 seconds with 12 queries