Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8516481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:26:29+00:00 2026-06-11T05:26:29+00:00

<?php # session session_start(); # check that session is set and is valid if(!isset($_SESSION[‘login’]))

  • 0
<?php
# session

session_start();

# check that session is set and is valid

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

      $kword = $_POST["kword"];

      function boldText($text, $kword) {
    return str_replace($kword, "<strong>$kword</strong>", $text);
}
      $testin1 = substr($kword,0,1);
if($testin1 == "") {
print "<strong>No Keyword or a Keyphrase Entered, Please return to the '<a href='keyword_search.php'>Keyword Search Page</a>'</strong>";
}
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 "<table border=0 cellpadding=10>";
echo "<tr align = center bgcolor=white>
<td><b>Company Name</b></td><td><b>Section</b></td><td><b>Question</b></td><td><b>Answer</b></td>" ; 
 while($info = mysql_fetch_array( $data )) 
 { 

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

  </p>
  </div>
  <div class="footer"><a href="logout.php"><br />
  Logout</a> | <a href="index.php">Index</a>  |  <a href="keyword_search.php">Back</a></div>
</div>
</body>
</html>

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?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:26:31+00:00Added an answer on June 11, 2026 at 5:26 am

    You can create a function to do so, and call it prior to echo’ing the variables.

    Instead of: $info['question'] use boldText($info['question'], $kword)

    function boldText($text, $keyword) {
        return str_ireplace($keyword, "<strong>$keyword</strong>", $text);
    }
    

    As a side note, don’t forget to escape $kword with mysql_real_escape_string() before using it in a SQL query, or even better, consider using MySQLi or PDO since mysql extension is strongly discouraged

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
<?php $userid = $_POST[userid]; $pword = $_POST[pword]; # session session_start(); # check that session
<?php session_start(); if(isset($_POST['sessionNum'])){ //Declare my counter for the first time $_SESSION['initial_count'] = $_POST['sessionNum']; $_SESSION['sessionNum']
I have a very simple test page for PHP session. <?php session_start(); if (isset($_SESSIONS['views']))
Here is the code: <?php //Starting session session_start(); //Includes mass includes containing all the
Here is te code: <?php //Starting session session_start(); //Includes mass includes containing all the
When I execute this following code for example: cart.php?p=1&action=add <?php session_start(); if (isset($_GET['p']) &&
When I use PHP header redirection, all session variables are lost... Some people say
In my login script I have put a checkbox that people can check if
I'm using PHP 4.3.9, Apache/2.0.52 I'm trying to get a login system working that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.