PHP If Statement - Help ;)

MoFish said:
If I look at the design view on dreamweaver, its there, but when i actually look at it through the browser, its vanished! :(
Hence why you shouldn't rely on a software program to generate markup.

As Beansprout posted, clean up and ensure your HTML is valid - this will iron out bugs like the ones you are experiencing.

I imagine the reason you aren't seeing "Hello Why Cant I See This" is, if you look at the relevant code:
Code:
<td valign=top>
    <table width=100% height=100% callpadding=0 cellspacing=0 class="main">
        <tr> 
            <td width=625 height=* valign=top></td>
        </tr>
    </table>
  </span>
  Hello Why Cant I See This 
</td>

  • You have a closing </span> tag, which relates to no other tag in that block.
  • Within the enclosing table cell (<td valign=top>), you have a <table> of height and width 100% - ergo it will fill that entire cell.
  • Your text is placed after this table - I guess the browser is giving the enclosed table precedence over that text.

Move your text to the table-cell within that 100% HxW table:
Code:
<td valign=top>
    <table width=100% height=100% callpadding=0 cellspacing=0 class="main">
        <tr> 
            <td width=625 height=* valign=top>Hello Why Cant I See This - well you can now.</td>
        </tr>
    </table>
  </span>
</td>

Better yet, clean up your code first (I simply ran the page through Tidy):

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

<style type="text/css">
    @import "style.css";  
</style>
    <title>
      MoFish
    </title>
<style type="text/css">
 div.c1 {text-align: center}
</style>
  </head>
  <body class="background-colour">
    <div class="c1">

      <table width="800" height="98%" cellpadding="0" cellspacing="0&quot;">
        <tr>
          <td width="1" height="100%" class="border-colour"></td>
          <td width="798" height="100%" class="main-section" valign="top">
            <table width="798" height="100%" cellpadding="0" cellspacing="0">
              <tr>
                <td width="798" height="120" valign="center" class=
                "banner-background-colour"></td>
              </tr>
              <tr>

                <td width="798" height="2" class="border-colour"></td>
              </tr>
              <tr>
                <td width="798" height="20" class="banner-where-are-you-colour"
                align="right">
                  04th February 2006
                </td>
              </tr>
              <tr>
                <td width="798" height="1" class="border-colour"></td>

              </tr>
              <tr>
                <td width="798" height="*">
                  <table width="798" height="100%" cellpadding="0" cellspacing=
                  "0">
                    <tr>
                      <td width="150" class="navigation-menu" valign="top">
                        <ul>
                          <li>
                            <a href="index.php?url=2">Home</a>

                          </li>
                          <li>
                            <a href="index.php?url=3">Forum</a>
                          </li>
                          <li>
                            <a href="index.php?url=4">Downloads</a>
                          </li>
                        </ul>

                      </td>
                      <td width="7" class="navigation-menu"></td>
                      <td width="1" class="border-colour"></td>
                      <td width="7" class="main-section"></td>
                      <td valign="top">
                        <table width="100%" height="100%" callpadding="0"
                        cellspacing="0" class="main">
                          <tr>
                            <td width="625" height="*" valign="top"></td>
                          </tr>

                        </table>Hello Why Cant I See This
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
          <td width="1" height="100%" class="border-colour"></td>

        </tr>
      </table>
      <table cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="7" height="1" class="border-colour"></td>
        </tr>
        <tr>
          <td width="800" height="*" valign="middle" align="center" colspan=
          "7">
            Best Viewed In 1024 x 768
          </td>

        </tr>
      </table>
    </div>
  </body>
</html>

But even better yet is to abandon <table>s for layout, that is not their purpose, and as you're discovering are a particularly confusing way to design a page. Use properly structured markup, marking up content with semantically relevant elements e.g. paragraphs in <p>s, headings in <h1>s and <h2>s, related elements in <div>s and <fieldset>s etc. and then use CSS to design the layout and fancy presentational stuff.
 
Last edited:
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
 
Why do you need an if statement for the isset and then else links to another page. Why can't you juse use the default: in the switch function?
 
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