Click here to Skip to main content
15,306,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey Every one,
I am working on my website i am having a job website and i have shown a box jobs by category but the problem is all category page have a same header which is extracting data from this. now i am doing SEO of my site for that i have to set Induvial meta title for that but when i try to put php code ( that i am using to show on home page) this code is not working in middle title on other page.

What I have tried:

Using this code on front home page
<pre><pre lang="PHP"><pre><div class="section">
    <div class="container">
     
        <div class="titleTop">
        <h3>Browse By <span>Categories</span></h3>
      </div>
      
        <ul class="row catelist">
            <?php  $i = 0;?>
            <?php if (!empty($categorys)): foreach ($categorys as $v_category) : ?>
            <li class="col-md-4 col-sm-6">
             <a href="<?php echo base_url(); ?>job/category_and_level_job/<?php echo $v_category->job_category_id; ?>/3"><?php echo $v_category->job_category_name; ?> </a>
             
           </li>
            <?php
                    endforeach;

                    ?>

                   
            <!--get all category if not this empty-->
            <input type="hidden" id="countOfi" value="<?php  echo $i++;?>">
            <?php else : ?>
            <!--get error message if this empty-->
            <li> There is no record for display </li>
            <!--/ get error message if this empty-->
            <?php
                    endif; ?>
          </ul>
       
      </div>
      
     
  </div>
  <!-- Categories ends -

and when i try to put this code
PHP
<pre><?php echo $v_category->job_category_name; ?>
into Meta title code is not working showing blank or empty space please some one rewrite this code
PHP
<pre><?php echo $v_category->job_category_name; ?>
which will work on other page also
Posted
Updated 15-Apr-21 1:49am

1 solution

Web pages, whether php or otherwise, do not communicate with other by default.

If you wish to transmit data between pages you either have to build the value into a link that calls the next page and extract it from there ($_GET) or it can be passed to all the pages via $_SESSION - but that requires you create a session. Also, you could use a cookie.

When a web page is put on a client it is "stateless" and is forgotten by the web server (that's why the internet can work with so many users). If you want the server to remember anything between pages you need to set that up (session) - or you can just take the data and pass it around (usually easier and my first suggestion).
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900