SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    London
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi I am a very new to PHP and MySQL, I have been working through Kevin Yanks tutorial which was great!
    Anyway, I have my site up and running and am trying to make it look a little more intersting with the use of tables to provide borders etc. I have produced a page which I would like to use as a SSI displaying text pulled from the database within this page. When I use:
    <?php
    include ('name of page');
    ?>

    The text from my database is displayed below or underneath the borders I have created etc!

    Could any one provide some detail of how you specify where text pulled from a MySQL table is displayed within a SSI.
    My first experiement with SSI's was a success because I was only including some buttons and logos at the top of a page, so the text was included directly below this and all looked fine. Now I have produced tables that are located above, on the left and below and I would like my results displayed in the middle of these tables/borders.
    I hope this makes some sense?
    Many thanks
    Last edited by kevin1; Mar 3, 2001 at 06:22.

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by kevin1
    I hope this makes some sense?
    Not really Can you provide more information?

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK then - if you have a design where the content is neatly laid out - "wrapped-up" - in tables then put your php code right into the appropriate cells.

    eg:

    <html>
    <head><title></title></head>
    <body>
    <table><tr>

    <!-- Left Nav Column -->
    <td width=100>
    <?php include("left_nav.php"); ?>

    <!-- Main Contents -->
    <td>
    <?php include("database_driven_main_contents.php") ?>
    </tr>

    <!-- Common Page Footer -->
    <tr><td colspan=2>
    <?php include("common_footer.php"); ?>

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

    Hope that's kinda correct - not tested.

    If I'm off the mark understanding your query then it might be an idea to post your html.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    London
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the code freaky but I still seem to have the same problem in that the headers and footers are displayed correctly but the contents does not go into the table where I would like to see it displayed. I will provide the code I have used please don't laugh too much as its very basic, a bit like me realy.

    I'm sure it is something very fundamental that I am doing incorrectly but if you have the time to help it would be greatly appreciated!

    PS Thanks for the advice you have provided already (Nice beard).
    ------------------------------------------------------------
    <!-- common_header.php -->
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF">
    <table width="100%" border="0" cellPadding=0 cellSpacing=0 bgcolor="#CCCCCC">
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>
    -----------------------------------------------------------
    <!-- left_nav.php -->
    <html>
    <head>
    <title></title>
    </head>

    <body bgcolor="#FFFFFF">
    <tr bgcolor="#CCCCCC">
    <td>&nbsp;</td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <table width="85%" height="100% border="0" cellpadding="0" cellspacing="0">
    <tr bgcolor="#CCCCCC">
    <td width="15%">
    <div align="center"></div>
    </td>
    <td rowspan="2" bgcolor="#0000FF" valign="top">
    <div align="center"></div>
    </td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="15%">
    <div align="center"></div>
    </td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="15%">
    <div align="center"></div>
    </td>
    </tr>
    </table>
    </body>
    </html>
    ------------------------------------------------------------
    <!-- Common Page Header -->
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF">
    <table width="100%" border="0" cellPadding=0 cellSpacing=0 bgcolor="#CCCCCC">
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>
    -----------------------------------------------------------

    <!-- admin.php -->
    <html>
    <head>
    <title>Subject Management System</title>
    </head>
    <body>
    <H1>Subject Management System</H1>
    <UL>
    <LI><A HREF="subjects.php">Search Subjects </A>
    <LI><A HREF="authors.php">Manage Authors</A>
    <LI><A HREF="cats.php">Manage Subject Categories</A>
    <LI><A HREF="newsubject.php">Add a New Subject </A>
    </UL>
    </body>
    </html>

    What I am trying to do is use SSI's for headers/footers and left nav_bar on all pages. I would like to see my text either in a cell agacent to the nav_bar or simply just sitting next to the nav_bar. I've been messing about with this all day, help!

    Thanks again Kevin1

  5. #5
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in your header, footer, etc... files, you have to delete all html and body tags, just the html betweet <body> and </body>
    better now?

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    London
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks iBram007 but even after I have got rid of all the tags etc I still end up with my admin.php page displayed below the nav_bar and not next to it?

    Any thoughts, here is the code!

    <!-- common_header.php -->


    <body bgcolor="#FFFFFF">
    <table width="100%" border="0" cellPadding=0 cellSpacing=0 bgcolor="#CCCCCC">
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </body>
    -----------------------------------------------------
    <!-- left_nav.php -->

    <body bgcolor="#FFFFFF">
    <tr bgcolor="#CCCCCC">
    <td>&nbsp;</td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <table width="85%" height="100% border="0" cellpadding="0" cellspacing="0">
    <tr bgcolor="#CCCCCC">
    <td width="15%">
    <div align="center"></div>
    </td>
    <td rowspan="2" bgcolor="#0000FF" valign="top">
    <div align="center"></div>
    </td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="15%">
    <div align="center"></div>
    </td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td width="15%">
    <div align="center"></div>
    </td>
    </tr>
    </table>
    </body>

    ----------------------------------------------------

    <!-- Common Page Header -->

    <body bgcolor="#FFFFFF">
    <table width="100%" border="0" cellPadding=0 cellSpacing=0 bgcolor="#CCCCCC">
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </body>
    ----------------------------------------------------

    <!-- Common Page Header -->
    <?php include('common_header.php'); ?>

    <!-- Left Nav Column -->
    <td width=100>
    <?php include('left_nav.php'); ?>

    <!-- Main Contents -->
    <td>
    <?php include("admin.php") ?>
    </tr>

    <!-- Common Page Footer -->
    <tr><td colspan=2>
    <?php include('common_footer.php'); ?>

    I'm sure were getting close now!

    Thanks again Kevin1

  7. #7
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kevin1, your code is a mess

    To put your problems into perspective, I suggest you do this. Display the problematic page in your browser. Now save or print the source code from your browser. Now look through that source code and remember this. The final result of running your php script and all the includes is that an html document gets sent to the browser. So what the browser receives should be a nicely formed HTML document! This should take this form (at a basic minimum - I'm not up on the w3 html4 specs )

    Code:
    <html>
       <head>
          <title>Title</title>
       </head>
       <body>
           Blah blah blah
       </body>
    </html>
    So that's one pair of html, head, title and body tags - no more! All your content must be within the body tags. At the moment you are including several body tags.

    Also, you have poorly formed tables in left_nav.php, "Common Page Header" and elsewhere. You have <td>s and <tr>s outside of enclosing <table></table> tags.

    Again, if you look at the source code that ends up being sent to the browser you will get a better picture of what is going wrong.

  8. #8
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Indeed Freakysid
    Kevin1, don't try to create a table with includes, in the header, you have to put a table like this: <table></table>
    Not end with a </tr> and restart in the next include with a new <tr> that's too difficult.
    Try to keep it easy.

  9. #9
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    London
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks freakysid and iBram for the words of wisdom, I shall scrap my includes and start again with something very simple. Once I have something running I will add additional stuff as required. Thanks for the tip about viewing the source code of the page with includes, I see what you mean, a big mess!

    Silly me I thought this would be a relatively simple task!

    I know this is a bit cheeky but if you would consider providing a simple examle I would be very grateful (please!!!)


  10. #10
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    London
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks freaky and iBram I think I,m there!
    I had no overall idea of the concept I was working with, viewing the 3 includes together with the source code from my databse made me realise what a load of rubbish was being sent to the browser!

    I have to put my hands up and say that I think the main problem was I though I would be a little clever and use Dreamweaver to quickly construct some tables in conjunction with the formatting and positioning etc. As you pointed out freaky the code was a mess with tons of superfluous rubbish.

    I will stick to coding myself and good old MS Notepad in future. This has been my first weekend as a sitepoint member and I must admit it been a great help and a learning experience!

    Thanks again Kevin1


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •