PHP If Statement - Help ;)

Associate
Joined
29 May 2005
Posts
144
PHP If Statement - RESOLVED!

Hello All.
Trying to do a similar if statement to my cold fusion one in PHP but am not sure on the syntax of PHP, as im just starting to learn it. I gave it a stab in the dark, but oviously didnt work. ;) could someone point me in the right direction. I tryed but failed. Thanks MoFish

Code:
<cfif isDefined("url.id1")>	
  <cfif #url.id1# EQ 2>
<cfinclude template="home.php">
  <cfelseif  #url.id1# EQ 3>
<cfinclude template="forum.php">
  <cfelseif  #url.id1# EQ 4>
<cfinclude template="downloads.php">
</cfif>
<cfelse>
  <cfinclude template="home.php">	
</cfif>

Code:
<if isDefined("url.id1")>	
  if ($url.id1$ == 2){
<?php include("home.php"); ?>;
  }elseif  ($url.id1$ == 3){
<?php include("forum.php"); ?>
  }elseif  ($url.id1$ == 4>{
<?php include("downloads.php"); ?>	
  <elseif>
<?php include("home.php"); ?>	
</if>
?>
 
Last edited:
huston we have a problem ;)

I currently have my navigation getting its values from a navigation.php file. Inside the navigation.php file I have the following.

Code:
<p>
  &gt; <a href="index.php?url=2">Home</a>
  <br>
  &gt; <a href="index.php?url=3">Forum</a>
  <br>
  &gt; <a href="index.php?url=4">Downloads</a>
</p>

I then have an index.php file, with a main div, in which the following is located.

Code:
<?php
if isset($_GET["url"]) {
    switch ($_GET["url"]) {
        case 3:
        include("forum.php");
        break;
        case 4:
        include("downloads.php");
        break;
        default:
        include("home.php");
        break;
    }
else
    include("index.php");
?>

Is this setup correctly? I'm getting the following error when trying to load the index.php

Parse error: parse error, unexpected T_ISSET, expecting '(' in on line 57

soz, im thick ;)
 
next question is ... drumroll ... DIVS!

Should I be using fixed div's or divs with %'z! I've been trying to get this DIV in the middle of the page forever! but If i shrink the window slightly it goes all haywire, and appears to be bigger at one side form the other! ;) Also I can set it up for 1024x768 to be in the middle, but when I change to 1280x1024 it messes up again. Whats the best thing to do here? ;)

Oh heres the link incase your interested in what sorta mess im making, yep a big one ;)

LINK

Code:
<div style="position:absolute; left:20%; top:0px; width:750px; height:100px">Banner
</div>
 
Last edited:
OK, I've changed some stuff around and got the DIV's the way I want them, and started on some CSS. Ive come accross a problem however. Im trying to input text into my main section of the site, but it doesnt seem to display it at all. it's like hidden or something wierd. I'm not sure where it is. If you look at my souce code for my page, you will see the following:

Code:
Hello Why Cant I See This

Its quite neer the bottom of the source code. Im trying to display that in the main section of the page, but having no luck. I must be doing something wrong somewhere. :o

Does anyone see why this would be doing this or what I have dont wrong?

LINK TO PAGE
 
Ahh I see why It was doing that, because I was using an include, I forgot to take the head tags out the other page. oops! How about now?

Ahh I suck at the indenting thing! ;) :p Think its ready to talk! :p
 
Last edited:
Augmented said:
Only if you're using the design-view (WYSIWYG) to generate the code for your layout. It's well-known for generating bloated, outdated and invalid code.

If you're coding it yourself and only using the code-view, then it's not an issue :).

Oh I See. I'm still having a problems displaying any information in my Main table. If I look at the design view on dreamweaver, its there, but when i actually look at it through the browser, its vanished! :(
 
Alright, I'm cleaned up now I think, Thanks for all the replys, really appriciate it. Have another question however ;) I have a DIV, and am wanting it moved over the the right hand side of my page a bit, but cant figure out how to do it. I've tryed a few things including Left:50%; to try indent it from the left side, didnt work.

Code:
			<div id="News-DIV">
				<div>Welcome To My Home Page</div>
			</div>

If you look at the image below, you can see my problem. (The Highlighted Pink DIVs)

The First image is my current DIV.
The Second Image Is where I want it to be (edited in photoshop to help understand the problem)

div8is.jpg
 
Im not sure, im still learning PHP and dont know how it all works as yet, I just throught that was the way to go around doing it. Got taught to do cold fusion if statements a while back, so thought it would be similar for PHP. I understand now, there are much easyier methods of doing it however... as for my question about moving the DIV over from the left edge, im still not sure how to do it. I tryed, left, padding, margin but couldnt seem to get it off the side at all.
 
Beansprout said:
That's one of the things I tidied :)

I thank you for that. I eventually got it, margin-left did the trick.

Cant get the following DIV's side By side now though ;) i've tryed setting the margin-top the same for both, and setting the top the same for both, but that didnt work. (talking about the dark grey DIVS)

div26fj.jpg
 
Last edited:
Back
Top Bottom