The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End I am a total newbie to this

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #164554

    I would very much like to place the following code on to a new site I am building. I know about changing the CSS and I placing the div class in the space I want the jpgs to go on the page but where do I place the actual php coding?? I know it is going to be so straightforward but, as I say, I am totally new to PHP coding.
    I placed the codce at the top of the web page and I had the page set as a hmtl but then changed it to a phtml extension to see if it was something to do with the server but I am probably barking up the wrong tree
    Thanking you in advance for any help you can give.


    Does your web host support php? Most servers that support php are configured to recognize the .php file extension for php scripts.


    yes web host supports php. That isn’t the problem – the problem is me! I don’t know exactly where to place the php code – is it in the same page as the ‘echo’ or is it in a separate php page or what? If on the same page – is it at the top, in the ‘head’ or ‘body’ sections? I am at a loss really


    Well, one of the cool things about PHP (object oriented guys would spit out their beer about now) is the fact that you can just put it inside a bunch of HTML.

    » spits out beer «

    Seriously, though, even if you’re not doing object-oriented code (and you are most likely not), it is beneficial to think of your PHP code in two different categories: logic and templates.

    Some PHP code is directly related to displaying things on the output html page: that’s templating stuff. Other code does “work” that is not directly related – makes decisions, gets/organizes data, “behind-the-scenes” work.

    Generally speaking, the work should go first (at the top of your script), and the templating stuff (including all of your plain HTML) should go afterwards (at the bottom). It will save you a lot of grief at some point.

    The script you’re talking about is, in fact, already organized this way:

    $data = get_data("");
    $weather_class = format_result(get_match('/<yweather:condition  text="(.*)"/isU',$data));
    //  etc. ...

    goes at the top, and then your HTML markup follows at the end (with the <?php echo $weather_class; ?> included wherever you want it to appear).


    Thanks to both of you for your answers – they have really spelt it out to me in a language I can understand and I am very grateful to you

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.