473,811 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4939
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.u k> 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
2292
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 from being a "language internist" (on Python or anything else) so go easy on me if this is stupid - it just seemed quite elegant to me as a relative newbie in town :-) I also havent got a clue whether this would be easy or even possible
8
1882
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 Box (lstRegion) is selected East or West. Basically the areas will change when East or West is selected in lstRegion. The data comes from an SQL Server view, and my current non-working code is as follows, my syntax in the SQL statement is...
4
4466
by: TheKeith | last post by:
I just wrote the following script for something I'm working on: ---------------------------------------------------------------------------- ------------------- <html> <head> <script type="text/javascript"> function KP_growit(subject,widthto,heightto) { var target = document.getElementById(subject);
3
2321
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 five weeks of sales for each category by using a conditonal format to highlight these top five weeks. I've been trying to find a way to do this but have not been sucessful looking through many books on Access and in reading the user groups. If...
4
4690
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
8519
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 perfectly. However, I have code that runs under the ON CLICK event. The code changes the focus to other controls, which means the conditional formatting is no longer displayed. This part makes sense to me. Here's what doesn't make sense. The last...
5
2909
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
7591
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. How is it possible? Please help me. Thanks in advance.
16
1765
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 will get set to 1 and the 1st if statement will be executed. What actually happens is that when I hit submit, the form stays where it is, for example if the form where the submit button is located is on the form other.php, then when I hit submit...
8
1979
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 syntax of what I'm trying to do... The structure I'm working on is Database Connection Select DB record occuring "Today" - have this working with BETWEEN statement DO UNTIL RS.EOF IF RS(title) < FromTime or >UntilTime Then
0
9722
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...
1
10393
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
10124
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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...
0
6882
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
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
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
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.