473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Conditional statement not working

This should be so easy, but it is not working.

What should happen is that if $p=home in the url then it displays
home.php and if $p does not equal home then it displays page.php which
is a template.

What am I missing?
<?php
// display page

if (@$p == $_GET['home']){
include ('pages/home.php');
} elseif (@$p != $_GET['home']){
include ('pages/page.php');
}else{
include ('pages/home.php');
}
?>
Jul 17 '05 #1
2 4921
Steve Fitzgerald <sf@mnetsys.com> wrote:
This should be so easy, but it is not working.

What should happen is that if $p=home in the url then it displays
home.php and if $p does not equal home then it displays page.php which
is a template.

What am I missing?

<?php
// display page

if (@$p == $_GET['home']){
$p is actually empty here. If $_GET['home'] is also empty the above
statement would be true.
include ('pages/home.php');
} elseif (@$p != $_GET['home']){


As $p is always empty, the above would be true if $_GET['home'] is not
empty.

If I understood you correctly, you have a parameter called 'p' in your URL
which sometimes is set to "home", sometimes not.

So you would check:

if (isset($_GET['p']) && $_GET['p']=="home"){
include ('pages/home.php');
} elseif (isset($_GET['p']) && $_GET['p']!="home"){
include ('pages/page.php');
}else{
include ('pages/home.php');
}

HTH;
JOn
Jul 17 '05 #2
It worked! Thanks.

Jon Kraft <jo*@jonux.co.uk> wrote in message news:<bm************@ID-175424.news.uni-berlin.de>...
Steve Fitzgerald <sf@mnetsys.com> wrote:
This should be so easy, but it is not working.

What should happen is that if $p=home in the url then it displays
home.php and if $p does not equal home then it displays page.php which
is a template.

What am I missing?

<?php
// display page

if (@$p == $_GET['home']){


$p is actually empty here. If $_GET['home'] is also empty the above
statement would be true.
include ('pages/home.php');
} elseif (@$p != $_GET['home']){


As $p is always empty, the above would be true if $_GET['home'] is not
empty.

If I understood you correctly, you have a parameter called 'p' in your URL
which sometimes is set to "home", sometimes not.

So you would check:

if (isset($_GET['p']) && $_GET['p']=="home"){
include ('pages/home.php');
} elseif (isset($_GET['p']) && $_GET['p']!="home"){
include ('pages/page.php');
}else{
include ('pages/home.php');
}

HTH;
JOn

Jul 17 '05 #3

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

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
8
by: Guy Hocking | last post by:
Hi there, I am having a few problems compiling a list box that is conditional on what is selected in another list box. What i need is a List box (lstArea) that displays one thing when the List...
4
by: TheKeith | last post by:
I just wrote the following script for something I'm working on: ---------------------------------------------------------------------------- ------------------- <html> <head> <script...
3
by: Chuck Reed | last post by:
I am working on a sales report where I show weekly sales by category for each of the 52 weeks in the year. Each record in my table/report has the 52 weeks of sales in it. I want to highlight to top...
4
by: mux | last post by:
Hi I found out that the following piece of code throws an error. 1 #include "stdio.h" 2 3 int main() 4 { 5 int a,b; 6 a= 10;
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
5
by: paulo | last post by:
Can anyone please tell me how the C language interprets the following code: #include <stdio.h> int main(void) { int a = 1; int b = 10; int x = 3;
43
by: dev_cool | last post by:
Hello friends, I'm a beginner in C programming. One of my friends asked me to write a program in C.The purpose of the program is print 1 to n without any conditional statement, loop or jump. ...
16
by: Art | last post by:
Can anyone help. I've tried scaling down a script to the bare minimum and it still is not working correctly. What I think should happen is that when the field app_fname is blank, that $hold_chk...
8
jschrader
by: jschrader | last post by:
I am trying to write a conditional Statement in ASP based on dates/times in a database entry. I'm basically a ASP/web designer and try my best to get into the fun coding, so not sure as to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
Oralloy
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,...
0
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,...
0
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...

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.