如何为每个HTML页面设置不同的元标题和描述?

时间:2019-06-14 13:10:25

标签: php html

我是用户,而不是开发人员,但必须负责。我在public_html / index.php中的代码如下:

<title>abcxyz</title>
<meta name="description" content="abcxyz>
<meta name="google-site-verification" content="h6tGrelLZ7k8OFzpXkJsOCDKxGChHoGs-y16DY8JuwQ" />
<meta name="google-site-verification" content="xgZkRTmPS-FeH494yBlk1MKYyXU4W5Gd8y0t2IE0daM" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">

现在所有页面都具有相同的meta标签,我有2个产品页面,但是只有一个product.php,如何设置2个不同的meta标签?如有必要,如何找到page_id,标题...?

product.php

<section id="main">
  <div class="wraper">
    <div class="main">
      <div class="row">
        <div class="col-xs-24 col-sm-16 col-md-17 col-sm-push-8 col-md-push-7 col">
          <div class="mainbody">
            <div class="head">
              <h3><?=$lang['menu']['sanpham']?></h3>
              <div class="gach"></div>
            </div>
            <div class="content">
              <?php
                $tbl=new table('products');
                if($_GET['id'])
                  $id=intval($_GET['id']);
                  $res = $tbl->loadOne(' id='.$id.' ' );
                  $row = mysql_fetch_object($res);
                  if($_SESSION['lang1']=='vi'){
                    $name=$row->name;
                    $details=$row->summary;
                    $link=convert($row->name);
                  }else{
                    $name=$row->name_en;
                    $details=$row->details;
                    $link=convert($row->name);
                  }
              ?>
              <h1><?=$name?></h1>
              <div class="detail"><?=$details?></div>
              <div class="otherdetail">
                <h3><?=$lang['menu']['cacsanphamkhac']?></h3>
                <ul>
                    <?php
                        $tbl=new table('products');
                        $limit = 20;
                        $nume = 10;
                        $res = $tbl->loadPaging($start,$nume,$limit,'where   id!='.intval($_GET['id']).'  ','order by id desc' );
                        if(mysql_num_rows($res) ==0)
                          echo "<p style='text-align:center; color:red'>Empty!</p>";
                        else{
                          while ($row = mysql_fetch_object($res)) {
                            $id=$row->id;
                            if($_SESSION['lang1']=='vi')
                              $name=$row->name;
                            else
                              $name=$row->name_en;
                            $link=convert($name);
                    ?>
                    <li><a href="<?=$root?>chi-tiet/<?=$id?>/<?=$link?>.html" ><?=$name?></a></li>
                    <?php }} ?>
                  </ul>
              </div>
            </div>
          </div>
        </div>
        <div class="col-xs-24 col-sm-8 col-md-7 col-sm-pull-16 col-md-pull-17">
          <?php include "source/left/left.php";?>
        </div>
      </div>
      <div class="row">
        <div class="col-md-24">
          <?php include "source/public/footer_other.php";?>
        </div>
      </div>
    </div>
  </div>
  <!-- Go to www.addthis.com/dashboard to customize your tools -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5cfcbefe582d68b7"></script>

代码

<section id="main">
    <div class="wraper">
        <div class="main">
            <div class="row">
                <div class="col-xs-24 col-sm-16 col-md-17 col-sm-push-8 col-md-push-7 col">
                    <div class="mainbody">
                        <div class="head">
                            <h3><?=$lang['menu']['sanpham']?></h3>
                            <div class="gach"></div>
                            <div class="ms"><span class="sign_in"><?=$lang['menu']['mausac']?></span>&nbsp;&nbsp;&nbsp;<span class="sign_in">(click here)</span></div>
                            <div id="sign_box" style="display:none">
                                <div id="an"><img src="<?=$root?>images/close_color.png" width="24" height="24" /></div>
                                <?php
                                    $tbl=new table('category2');
                                    $res = $tbl->loadOne('1=1');
                                    while($row = mysql_fetch_object($res)){
                                        if($_SESSION['lang1']=='vi')
                                            $name=$row->name;
                                        else $name=$row->name_en;
                                ?>
                                <div class="mau">
                                    <div class="tenmau"><?=$name?></div>
                                    <div class="imgmau"><img src="<?
                                        $chuoi=$row->image;
                                        if($chuoi1=substr($chuoi,0,7)=='http://')
                                        echo $chuoi;
                                        else {
                                        if($chuoi=='')
                                        echo $root."images/noimage.jpg";
                                        else
                                        echo $root."uploads".$chuoi;
                                        }
                                    ?>" width="100" height="53" /></div>

                                </div>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="content product row">
                            <?php
                                $tbl=new table('products');
                                if(isset($_GET["start"])){
                                    $start = $_GET["start"];
                                }
                                if(!isset($start)) $start = 0; $limit = 12; $nume = 10; $pagename =$root."san-pham/"; $res = $tbl->loadPaging($start,$nume,$limit,'where  1=1 and block=0 ','order by id asc' );
                                if(mysql_num_rows($res) ==0)
                                    echo "<p style='text-align:center'>Empty</p>";
                                else{
                                    while ($row = mysql_fetch_object($res)) {
                                        $id=$row->id;
                                        if($_SESSION['lang1']=='vi'){
                                            $name=$row->name;
                                            $details=$row->summary;
                                            $link=convert($row->name);
                                        }else{
                                            $name=$row->name_en;
                                            $details=$row->details;
                                            $link=convert($row->name);
                                        }
                            ?>
                            <div class="col-xs-24 col-sm-8 col-md-8">
                                <div class="item">
                                    <div class="thumb">
                                        <a href="<?=$root?>chi-tiet/<?=$id?>/<?=$link?>.html"><img src="<?
                                            $chuoi=$row->image;
                                            if($chuoi1=substr($chuoi,0,7)=='http://')
                                            echo $chuoi;
                                            else {
                                            if($chuoi=='')
                                            echo $root."images/noimage.jpg";
                                            else
                                            echo $root."uploads".$chuoi;
                                            }
                                            ?>"/>
                                        </a>
                                    </div>
                                    <h3><a href="<?=$root?>chi-tiet/<?=$id?>/<?=$link?>.html"><?=$name?></a></h3>
                                </div>
                            </div>
                            <?php } }?>
                        </div>
                    </div>
                </div>
                <div class="col-xs-24 col-sm-8 col-md-7 col-sm-pull-16 col-md-pull-17">
                    <?php include "source/left/left.php";?>
                </div>
            </div>
            <div class="row">
                <div class="col-md-24">
                    <?php include "source/public/footer_other.php";?>
                </div>
            </div>
        </div>
    </div>
    <!-- Go to www.addthis.com/dashboard to customize your tools -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5cfcbefe582d68b7"></script>
</section>

0 个答案:

没有答案