showing H1 tag text on page

Discussion in 'PHP' started by login, Oct 3, 2007.

  1. #1
    Hi.
    On some pages I have there is H1 tags. I want to repeat the text that is already in the H1 tag in the title of the page and one other place on the page. How can I do this with php? Is it a small code i can paste in?
    Sorry if the question is stupid, bur as you may understand I dont know anything about php:eek:
     
    login, Oct 3, 2007 IP
  2. dnahosting

    dnahosting Active Member

    Messages:
    385
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #2
    put something within the php stating:
    $keyword = "insert the keyword here";

    and wherever you want it to show up put:
    <?php echo $keyword ?>

    will that help?
     
    dnahosting, Oct 3, 2007 IP
  3. Grumps

    Grumps Peon

    Messages:
    592
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Make sure that the variable declaration is placed in a file that is shared among all the pages that u wanted. The first part

    $keyword = "insert the keyword here";
     
    Grumps, Oct 3, 2007 IP
  4. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Thanks all.
    That keyword is a H1 tag that is different on every page. I cant just use "keyword", I need to pull the keywords from the different H1 tags.
     
    login, Oct 3, 2007 IP
  5. dnahosting

    dnahosting Active Member

    Messages:
    385
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #5
    so you want the php to scrape the page, look for the <h1></h1> tags, save what is between the tags, and place it around the same page?
    all without modifying the pages?

    ::edit::
    is your site a template driven site? with header an footer templates etc?
     
    dnahosting, Oct 3, 2007 IP
  6. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #6
    Thats what I want, sorry for the bad explanation. Its template driven yes.
     
    login, Oct 3, 2007 IP
  7. dnahosting

    dnahosting Active Member

    Messages:
    385
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #7
    I havent been able to create an effective scraper that pulls certain parts out of the page yet so I'm sorry I not going to be able to help.
     
    dnahosting, Oct 4, 2007 IP
  8. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #8
    So I found that if I just paste

    <?php echo $row_recipe["name"];?>

    around my site, the keyword I want will be there. But if I paste this code in the title tag in the template where the title is the keyword is not showing up in the title tag. Why not?

    This is what I have on the template where the title tag is:

    ///Title of the site
    $site_title = $row_set["site_title"];

    and then:

    <title><?php echo $site_title; ?></title>


    Making the title tag like this:

    <title><?php echo $row_recipe["name"];?> <?php echo $site_title; ?></title>

    will not work.
     
    login, Oct 5, 2007 IP
  9. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #9
    So I dont give up on this one. I need the keywords in the h1 tag to show up in the title tag, how can I do that?
     
    login, Oct 8, 2007 IP
  10. Synchronium

    Synchronium Active Member

    Messages:
    463
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #10
    Look up preg_match()
     
    Synchronium, Oct 8, 2007 IP