Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2004
    Location
    Manchester, UK
    Posts
    2,130

    Unhappy Parsing HTML page and adding tags at runrime

    Hi there,

    I have a PHP book and have leant on many other resources to try and answer my question but without success.
    As VBForums always tends to help me out with my Visual Basic problems - I thought I might try the same for PHP.

    The Problem

    I have a HTML document which has a table in it.
    The table has 2 columns and 2 rows.
    In the first column of each row is a short piece of text denoting the progress of the php script. Is it possible for PHP to be able to add a tick image to the second column of each row when the associated process has passed.
    (I would of course use the img src tag).
    However, how can I get PHP to add this tag at runtime and in the right cell of the table.

    Many thanks,

    Jord

  2. #2
    Join Date
    Dec 2003
    Location
    Earth
    Posts
    144
    What?

    You do know that php outputs the html?
    php can decide whenever you add html(that's kinda what it's for).

    If I understand you correctly... You are trying to do something like add someting if the conditions are right? For example a message board displays a different icon to indicate that the post has a new reply. Is this what you are getting at?
    if($php !== $javascript){
    echo "Good it's not supposed to be";
    }

  3. #3
    Join Date
    Jul 2004
    Location
    Manchester, UK
    Posts
    2,130
    Kind of, yes. I know PHP can add HTML to a document but the table will be hard-coded into the HTML document before the PHP script even starts. I then want php to somehow add an img src tag to this table at runtime of the php script.
    So I need PHP to:

    a) Find the right cell of the table
    b) Print the img src tag to it

    How do I have PHP parse the HTML document for this particular cell and then print inside of that cell.
    I am not trying to add something 'when the conditions ae right' the img src tag should be added whenever a piece of code has been passed.

    I hope that makes my problem clearer...

  4. #4
    Join Date
    Dec 2003
    Location
    Earth
    Posts
    144
    You are thinking things backwards.

    Either you need to embed the php into the html or you need to have php do all of it. I t doesn't seem to make sense to have php local parse local html (data mining of some sort I might understand).

    just as an example if you can't embed php into html just do a 'page.php':

    PHP Code:
    <!-- this is a php page but I can use html anywhere I want -->
    <html><head><title>This</title></head>
    <body>
    Stuff here

    <? // PHP stuff goes here

    $php_is "Your friend for writing html";

    // end php here
    ?>

    </body>
    </html>
    if($php !== $javascript){
    echo "Good it's not supposed to be";
    }

  5. #5

    templating

    You probably need templating. Search and learn some template engines like smarty or phplib

  6. #6
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    Actually, you don't need templating. If I understand your problem correctly, you want PHP to update a page as its running -- sort of displaying a live counter or status bar. Is this correct? If so -- you probably want to explore output buffering.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  7. #7
    Join Date
    Jul 2004
    Location
    Manchester, UK
    Posts
    2,130
    Originally posted by fyrestrtr
    Actually, you don't need templating. If I understand your problem correctly, you want PHP to update a page as its running -- sort of displaying a live counter or status bar. Is this correct? If so -- you probably want to explore output buffering.
    Yeah, thats right, but I don't know how to physically "place" the tick (progress) image in the correct part of the HTML document. ie. The table cell...

  8. #8
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    You'll need to use javascript if you want the update to be 'live' without a server request. PHP only runs on the server, so you need a client-side language such as javascript.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

Posting Permissions

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