php noob needs help with css

Discussion in 'Web Design and Development' started by Jasonbot, Aug 15, 2008.

  1. Jasonbot macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #1
    Hi everyone. I have an html site that I've converted to php with the help of a friend. Unfortunately he's very busy and I'm just hoping someone else can help me get it going.

    The html site is here:
    jasonbot.googlepages.com/index.html

    The php site is here:
    http://grupenet.com/jasonbot/main.php

    The problem I am currently experiencing is that the text in the php site (that I got via a switch statement) is not adhering to my stylesheets. I don't know how to fix it and I'm sure its a very basic thing that I need to do as I have a feeling that my <p> tags just wont cut it.


    the switch:
    PHP:
    <p align="center" id="middle">
    <?php
    $pg 
    $_GET['pg'];

    switch (
    $pg) {
    default:
    include 
    "home.html";
    break;
    }

    ?>
    </p>
    the css:
    HTML:
    p#middle{
    background:url(body.png) center repeat-y;
    margin-left:100px;
    margin-right:100px;
    padding-right:100px;
    padding-left:100px;
    margin:0;
    }

    thanks in advance
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You can move your align="center" to the CSS and have text-align:center; Tables are not allowed to go inside paragraphs. Check the site against a validator to see what type of errors you have. This should at least get you started.
     
  3. notnek macrumors 6502

    notnek

    Joined:
    Oct 25, 2007
    #3
    why have the switch in there? why not just have your $pg variable match up with the name of the file and include it?

    PHP:
    <?php

    // $pg = home in this case

    $pg $_GET['pg'];

    include(
    '/direct/path/to/$pg.php');

    ?>
     
  4. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
  5. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #5
    PHP5 is strict these days so...

    PHP:
    $pg=(isset($_GET('pg') && !empty($_GET('pg')) && intval($_GET('pg'))>0) ? intval($pg) : "1";
    That makes sure the $pg variable is set properly only if the URL has that argument, it's not blank and a valid integer. I default it to one since this seems to be a variable for a page number, and page 1 is a sensible default for their home page. I could add even more security to account for SQL injection and XSS issues such as trimming, stripping HTML tags, etc. - developers be aware of these things when working with $_GET globals.

    I suspect the OP will expand the branches of the switch to include more than just the default in the future. If not, then I agree the switch is not necessary.

    -jim
     
  6. Jasonbot thread starter macrumors 68020

    Jasonbot

    Joined:
    Aug 15, 2006
    Location:
    The Rainbow Nation RSA
    #6
    Guys come on.... I figured it. It was the fact that I was using <p> instead of <div> lol. Well thats sorted but now I got a problem with my linkies.

    If you look @ this page: grupenet.com/jasonbot/main.php?pg=connect
    I'm having some problems with my switch statement.

    •When I click one of the sublinks the page changes to the wrong content and teh links disappear
    •The image rollovers are funny :/

    Help please and thank you
     
  7. tyler785 macrumors newbie

    Joined:
    Aug 17, 2008
    #7
    The problem here is that you are using the same id name for the buttons in the top navigation. Rename your second nav buttons id names to something unique and update your onmouseover and onmouseout respectively.
     

Share This Page