How to pass data over url in modal bootstrap?

What code do I add to this to make search results emboldened? PHP?

  • I am learning PHP and decided to watch a tutorial on how to make a search engine. However, much like Google, I would like to make it so that all keywords typed by the user are emboldened. How can this be achieved? Thank you <?php //get data $button = $_GET['submit']; $search = strtolower($_GET['search']); if(!$button) echo "You didn't submit a keyword"; else { if (strlen($search)<=0) header( 'location:http://www.mysite.com' ); else { //connect to our database mysql_connect("localhost", "mysite_search","pass"); mysql_select_db("mysite_search"); //explode our search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //construct query $x++; if ($x==1) $construct .= "keywords LIKE '%$search_each%' OR description LIKE '%$search_each%' OR title LIKE '%$search_each%'"; else $construct .= " OR keywords LIKE '%$search_each%' OR description LIKE '%$search_each%' OR title LIKE '%$search_each%'"; } //echo out construct $construct = "SELECT * FROM search WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "Your search - '<b>$search</b>' - did not return any results.<p><p> Suggestions:<p> <li>Make sure all words are spelled correctly.</li> <li>Try different keywords.</li> <li>Try more general keywords.</li>"; else { echo "Showing 1-$foundnum of <b>$foundnum</b> results for '<b>$search</b>'<p>"; while($runrows = mysql_fetch_assoc($run)) { //get data $title = $runrows['title']; $description = $runrows['description']; $url = $runrows['url']; ?> <font face="verdana" size="2" color="blue"> <? echo "<a href='$url'>$title</a><br>" ?> </font> <font face="verdana" size="2" color="black"> <? echo "$description<br>" ?> </font> <font face="verdana" size="2" color="green"> <? echo "$url<p>"; ?> </font> <? } } } } ?>

  • Answer:

    You can use str_replace to put bold tags around the keywords. $title = str_replace($search, '<b>'.$search.'</b>', $runrows['title']); $description = str_replace($search, '<b>'.$search.'</b>', $runrows['description']);

xoroid@y... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.