SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2008
    Location
    uk
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic browser sheet issue

    Hi - I'm very new to this. I've been trying to get to grips with database driven web design. I'm in the early stages of learning HTML, PHP MySQL etc. That is what this question relates to.

    I've set up a input form that take a key value and queries a mysql database table which in turn returns a result - as this is very basic, the return is just a number eg 928. That result is echoed onto what appears to be a new page in my browser, a page which I didn't code for - the result just appeared that way.

    How do I specify the format of the output on this new page in my browser?

    Any assistance would be greatly appreciated.

    Best wishes (and Happy Holidays)

    Nigel

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    If you want the result formatted in some way, don't simply echo() it as text (which may be good enough for dev testing, but not production). Output the HTML you want with the result in it. eg.
    PHP Code:
    <?php
    .......
    echo 
    "<h1>Results</h1>\r\n";
    foreach(
    $query_result as $field_value)
    {
         echo 
    "<p>" $field_value "</p>\r\n";
    }
    .......

  3. #3
    SitePoint Member
    Join Date
    Nov 2008
    Location
    uk
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Food for thought there Jack.

    For clarification: are you saying that the table in the database should contain the HTML that formats the result??

    As an example I was thinking say of Yellow pages or maybe an Estage Agency/ Realtor website - you do a search, a list is returned on a page with a different format, you click on a name from the list and a new sheet is returned again with a different look, new information, pictures, buttons etc. Are you saying that all of that format and content info are stored in the db table and returned in the query results?

    Thanks again.

    Nigel

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    I suppose you could keep the mark-up in the database, but that isn't what I meant. I was thinking more of formating in the file indicated by the form's action attribute with the database results used in their corresponding places. i.e.
    PHP Code:
    echo "<h1>" $heading "</h1>\r\n";
    echo 
    "<div class='"$class "'>\r\n<p>";
    echo 
    $content;
    echo 
    "</p>\r\n</div>\r\n"
    For the secondary pages you could do the same sort of thing but use GET variables instead of POST variables.

    BTW, the "\r\n"s in the example aren't neccessary, they only make the code more readable in view-source.

  5. #5
    SitePoint Member
    Join Date
    Nov 2008
    Location
    uk
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jack

    I'll have to have a long look at this. Thanks for the steer.

    Best wishes

    Nigel


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
  •