Forum Moderators: coopster

Message Too Old, No Replies

Selection script

Stupid if conditionals!

         

ahmedtheking

11:45 am on Aug 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, ive got a prob here, first heres the script:

if ($cat!= "") {

print ("
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">
<tr>
<td style=\"border-bottom:solid 1px #3366CC;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">
<tr>
<td><img src=\"images/sitelayout/e04.gif\" width=\"21\" height=\"21\" alt=\" \" border=\"0\" align=\"left\"></td>
<td style=\"padding:5px; \"><h1><font color=\"#3366CC\">$Row[title]</font></h1></td>
</tr>
</table></td>
</tr>
<tr>
<td>$body</td>
</tr>
<tr>
<td>
");

require ('dir.php');

print ("
</td></tr>
</table>
");

} else {
$thecat = urldecode($cat);

print ("
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">
<tr>
<td style=\"border-bottom:solid 1px #3366CC;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">
<tr>
<td><img src=\"images/sitelayout/e04.gif\" width=\"21\" height=\"21\" alt=\" \" border=\"0\" align=\"left\"></td>
<td style=\"padding:5px; \"><h1><font color=\"#3366CC\">$thecat</font></h1></td>
</tr>
</table></td>
</tr>
<tr>
<td>
");

$catfile = "dir/".$thecat.".php";

require $catfile;

print ("
</td></tr>
</table>
");

}

I am loading a page into a template page, in this case called 'dirindex.php'. the variable '$cat' will allow the script to load the correct page. but, how can i do it so that if $cat is index or nothing, it will load the first statement and if it isnt index or nothing, it will load the else statement?

Im used to switch conditionals, but this is a bit small for a switch!

any ideas?

Netizen

11:51 am on Aug 12, 2004 (gmt 0)

10+ Year Member



I may be missing something here but can't you just do

if (empty($cat) ¦¦ $cat='index') {
// Execute code here
} else {
// Execute other code here
}

?

ahmedtheking

12:10 pm on Aug 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



no it doesnt like it!

[edited by: ergophobe at 2:46 pm (utc) on Aug. 12, 2004]
[edit reason] url deleted as per TOS [/edit]