Bolding a specifc variable in PHP throughout a page
<pre><code>&lt;?php
# session

session_start();

# check that session is set and is valid

if(!isset($_SESSION['login']))
   { header('Location: login.php');
}
?&gt;
&lt;body&gt;
&lt;div class="maincontainer"&gt;
  &lt;div class="keywordhead"&gt;
    &lt;div align="center"&gt;&lt;img src="Images/keyword_title.png" width="243" height="56" /&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="results"&gt;
  &lt;p&gt;
    &lt;?php

      $kword = $_POST["kword"];

      function boldText($text, $kword) {
    return str_replace($kword, "&lt;strong&gt;$kword&lt;/strong&gt;", $text);
}
      $testin1 = substr($kword,0,1);
if($testin1 == "") {
print "&lt;strong&gt;No Keyword or a Keyphrase Entered, Please return to the '&lt;a href='keyword_search.php'&gt;Keyword Search Page&lt;/a&gt;'&lt;/strong&gt;";
}
else {
   // Connects to your Database 
 mysql_connect("localhost", "root") or die(mysql_error()); 
 mysql_select_db("test") or die(mysql_error()); 
}
 mysql_real_escape_string($kword); 
 $data = mysql_query("select company_name, section_name, question, answer from company, rfp, section, question_keywords
where company.company_id = rfp.company_id
and rfp.rfp_id = question_keywords.rfp_id
and question_keywords.section_id = section.section_id
and keywords like '%$kword%';") 
 or die(mysql_error()); 

  echo "&lt;table border=0 cellpadding=10&gt;";
echo "&lt;tr align = center bgcolor=white&gt;
&lt;td&gt;&lt;b&gt;Company Name&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Section&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Question&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Answer&lt;/b&gt;&lt;/td&gt;" ; 
 while($info = mysql_fetch_array( $data )) 
 { 

 echo "&lt;tr&gt;"; 
 echo "&lt;td width = 130px&gt;".boldText($info['company_name'], $kword) . "&lt;/td&gt; ";
 echo "&lt;td width = 60px&gt;".boldText($info['section_name'], $kword) . " &lt;/td&gt;"; 
 echo "&lt;td width = 300px&gt;".boldText($info['question'], $kword) . " &lt;/td&gt;";
 echo "&lt;td width = 600px&gt;".boldText($info['answer'], $kword) . " &lt;/td&gt;&lt;/tr&gt;"; 
 } 
 echo "&lt;/table&gt;"; 
 ?&gt;

  &lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="footer"&gt;&lt;a href="logout.php"&gt;&lt;br /&gt;
  Logout&lt;/a&gt; | &lt;a href="index.php"&gt;Index&lt;/a&gt;  |  &lt;a href="keyword_search.php"&gt;Back&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>I am relatively new to PHP, and i was curious as to whether a certain function is possible. I have a keyword Search and the code for the results page is above. I would like to bold wherever the $kword variable appears on the page. is this possible? </p>

<p>Thanks</p>
